├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── stream │ │ └── crosspromotionsample │ │ ├── Constants.java │ │ └── MainActivity.java │ └── res │ ├── drawable-v21 │ ├── ic_menu_camera.xml │ ├── ic_menu_gallery.xml │ ├── ic_menu_manage.xml │ ├── ic_menu_send.xml │ ├── ic_menu_share.xml │ └── ic_menu_slideshow.xml │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ ├── ic_launcher_background.xml │ └── side_nav_bar.xml │ ├── layout │ ├── activity_main.xml │ └── nav_header_main.xml │ ├── menu │ └── activity_main_drawer.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ └── values │ ├── colors.xml │ ├── drawables.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── crosspromotion ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── stream │ │ └── crosspromotion │ │ ├── Ad.java │ │ ├── AdActivity.java │ │ ├── AdListFragment.java │ │ ├── Constants.java │ │ ├── CustomRequest.java │ │ ├── DatabaseHelper.java │ │ ├── LruBitmapCache.java │ │ ├── Utils.java │ │ └── VolleySingleton.java │ └── res │ ├── drawable-v21 │ ├── ic_menu_camera.xml │ ├── ic_menu_gallery.xml │ ├── ic_menu_manage.xml │ ├── ic_menu_send.xml │ ├── ic_menu_share.xml │ ├── ic_menu_slideshow.xml │ ├── icon_apk_circle.xml │ ├── icon_plus_fit_white.xml │ ├── icon_star_tiny.xml │ └── icon_verified_circle.xml │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable-xhdpi │ ├── icon_apk_circle_old.png │ ├── icon_plus_fit_white_old.png │ ├── icon_star_tiny_old.png │ └── icon_verified_circle_old.png │ ├── drawable │ ├── bg_rrect_install.xml │ ├── bg_rrect_install_selected.xml │ ├── bg_rrect_install_selector.xml │ ├── bg_rrect_rating.xml │ ├── bg_rrect_rating_selected.xml │ ├── bg_rrect_rating_selector.xml │ ├── ic_android_apk_icon_circle.xml │ ├── ic_launcher_background.xml │ ├── icon_googleplay.xml │ └── side_nav_bar.xml │ ├── layout-v21 │ └── item_main.xml │ ├── layout │ ├── activity_acp.xml │ ├── fragment_acp.xml │ └── item_main.xml │ ├── menu │ └── menu_main.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── server ├── addad.php ├── ads.get.php ├── class.ads.php ├── class.api.php ├── class.db_connect.php ├── class.helper.php ├── db.php ├── index.php ├── init.php ├── initialize.php └── sampledata.php └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | build/* 3 | */app.iml 4 | app/src/test/* 5 | app/src/AndroidTest/* 6 | app/build/* 7 | 8 | # Crashlytics configuations 9 | com_crashlytics_export_strings.xml 10 | 11 | # Local configuration file (sdk path, etc) 12 | local.properties 13 | 14 | # Gradle generated files 15 | .gradle/ 16 | 17 | # Signing files 18 | .signing/ 19 | 20 | # User-specific configurations 21 | .idea/* 22 | .idea/libraries/ 23 | .idea/workspace.xml 24 | .idea/tasks.xml 25 | .idea/.name 26 | .idea/compiler.xml 27 | .idea/copyright/profiles_settings.xml 28 | .idea/encodings.xml 29 | .idea/misc.xml 30 | .idea/modules.xml 31 | .idea/scopes/scope_settings.xml 32 | .idea/vcs.xml 33 | *.iml 34 | 35 | # OS-specific files 36 | .DS_Store 37 | .DS_Store? 38 | ._* 39 | .Spotlight-V100 40 | .Trashes 41 | ehthumbs.db 42 | Thumbs.db -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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 | [![GitHub release](https://img.shields.io/github/release/searchy2/AndroidCrossPromotion.svg?style=flat-square)](https://github.com/searchy2/AndroidCrossPromotion/releases) [![GitHub Release Date](https://img.shields.io/github/release-date/searchy2/AndroidCrossPromotion.svg?style=flat-square)](https://github.com/searchy2/AndroidCrossPromotion) [![Libraries.io for GitHub](https://img.shields.io/librariesio/github/searchy2/AndroidCrossPromotion.svg?style=flat-square)](https://github.com/searchy2/AndroidCrossPromotion) [![GitHub issues](https://img.shields.io/github/issues/searchy2/AndroidCrossPromotion.svg?style=flat-square)](https://github.com/searchy2/AndroidCrossPromotion) [![API](https://img.shields.io/badge/API-15%2B-blue.svg?style=flat-square)](https://github.com/searchy2/AndroidCrossPromotion) [![Github file size](https://img.shields.io/badge/Size-91%20KB-e91e63.svg?style=flat-square)](http://www.methodscount.com/?lib=com.github.searchy2%3AAndroidCrossPromotion%3A1.3.1) [![Library methods count](https://img.shields.io/badge/Methods%20count-332-e91e63.svg?style=flat-square)](http://www.methodscount.com/?lib=com.github.searchy2%3AAndroidCrossPromotion%3A1.3.1) 2 | 3 | # Android Cross Promotion 4 | 5 | Android Cross Promotion is a self hosted cross promotion platform for your own apps. Advertise your own apps within your apps easily. Setup in under 20 minutes! 6 | 7 | Android Cross Promotion is part of the Custom UI collection of ready-made, essential, and elegant Android code libraries. This library was created to give developers a way to cross promote their own apps without the need for bloated ad libraries or Google Play Services. Android Cross Promotion gives developers the ability to update the apps they are promoting from the backend and have changes reflected in their apps instantaneously. 8 | 9 | # Features 10 | * **Complete control** - add, remove, and update promoted apps in realtime. 11 | * **Dynamic updates** - changes are made via server, not in app code. 12 | * **Local storage** - promoted app data is cached for instantaneous loading. 13 | * **Smart caching** - changes to data are tracked to minimize network traffic. 14 | * **Small size** - adds very little bloat. 15 | * **Few methods** - uses far fewer methods than any ad libraries or Google Play Services. 16 | * **Miminal dependencies** - this library requires only one dependency! 17 | * **Highly customizable** - code can be easily modified and extended. 18 | * **Easy and fast** - integrate this libary into your project in 20 minutes! 19 | 20 | --- 21 | # 20 Minute Setup Guide 22 | 23 | ## Server 24 | 25 | ### Server Upload 26 | Upload all files in `server` to your web server. The backend can run from any subdomain or folder. 27 | 28 | Server Requirements: 29 | >PHP 5.5 - 5.6 30 | 31 | >MySQL 32 | 33 | >PDO Extension 34 | 35 | ### Database Setup 36 | Create a new database and user with all privileges. 37 | Open `db.php` and fill the following fields with your credentials. 38 | 39 | ```php 40 | //Database credentials. 41 | $C['DB_HOST'] = "localhost"; //usually localhost 42 | $C['DB_USER'] = "ray_crosspromo"; //DB user 43 | $C['DB_PASS'] = "12345678"; //DB password 44 | $C['DB_NAME'] = "ray_crosspromotion"; //DB name 45 | ``` 46 | Initialize your database by running `initialize.php` from your browser. 47 | 48 | ### Create App Promotion 49 | Currently, there is no GUI/Frontend to help you insert app data into the database. Instead, you can create app promotional listings directly in your database. 50 | Open the `ads` table in your database to create your app listings. 51 | 52 | A few sample app listings are provided as examples. 53 | 54 | ```text 55 | Main Ad Table 56 | * id - primary key. 57 | * fromUserId - id of user that created ad. 58 | * adType - category type of app data returned. 59 | * segment - campaign A/B segmentation. 60 | * location - geo targeting. 61 | * deviceVersion - limit ad to supported devices only. Use minimum API values (e.g. Android Nougat = 26) 62 | * weight - prioritize ad display frequency and order. Use 0-100. 63 | * price - cost of app in cents. (e.g. $0.99 = 99). 64 | * title, description, descriptionShort, category, rating, installs, version, developer, email, address, website - app details. 65 | * subtitle - ad secondary text/tagline. 66 | * linkUrl - app link. 67 | * packageName - app package name. 68 | * imgUrl, previewImgUrl - high and low res ad images. 69 | * videoUrl, previewVideoImgUrl - video URL and placeholder image URL. 70 | * text1, text2, text3 - extra customizable text fields. 71 | * number1, number2, number3 - extra customizable number fields. 72 | * createAt - ad created time in UTC. 73 | * updateAt - ad updated time. 74 | * startAt - ad campaign begins displaying. 75 | * endAt- ad campaign stops displaying. 76 | * removeAt- ad removed time. 77 | * views - ad views. 78 | * clicks - ad clicks. 79 | * sales - ad conversions/installs. 80 | ``` 81 | Once the app listings have been created, proceed to add it to your application. 82 | 83 | ## Android App 84 | 85 | ### Gradle Dependency 86 | Add this line to your `build.gradle` project. Use the latest release version for the version code. 87 | 88 | ```java 89 | repositories { 90 | maven { url 'https://jitpack.io' } 91 | } 92 | implementation 'com.github.searchy2:AndroidCrossPromotion:latest-version' 93 | ``` 94 | 95 | Add the following dependencies. 96 | 97 | ```java 98 | implementation 'com.android.support:appcompat-v7:latest-version' 99 | implementation 'com.android.support:design:latest-version' 100 | implementation 'com.android.volley:volley:latest-version' 101 | ``` 102 | 103 | ### Server Declaration 104 | Declare your custom ad server URL by adding a `CustomAds` metavalue to AndroidManifest.xml. 105 | 106 | ```java 107 | 108 | ``` 109 | 110 | ### Manifest Override 111 | Add `tools:replace="android:theme"` to your application tag in AndroidManifest.xml. 112 | 113 | ```java 114 | 120 | ``` 121 | This line allows you to override the library theme for customization. 122 | 123 | ### Theme Customization 124 | Add an `AdTheme` to your `styles.xml`. 125 | ```java 126 | 131 | ``` 132 | Using the default values allows you to match the library appearance to your app. 133 | 134 | # Usage 135 | 136 | Just add these lines whereever you want to open the cross promotion library, that's it. 137 | 138 | ```java 139 | Intent intent = new Intent(mContext, stream.crosspromotion.AdActivity.class); 140 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 141 | startActivity(intent); 142 | ``` 143 | This code starts the `AdActivity` Activity which loads your list of apps. 144 | 145 | --- 146 | # Customization 147 | 148 | 149 | `AD_DEVELOPER_ID` - Setting this value enables the Google Play icon in the Toolbar which links to your developer page with all your apps. 150 | Learn more about [Developer Pages](https://support.google.com/googleplay/android-developer/answer/6226441). 151 | 152 | `AD_TITLE` - Set a custom Toolbar title. Leaving this blank sets "More Apps" as the title by default. 153 | 154 | Here is an example: 155 | 156 | ```java 157 | Intent intent = new Intent(mContext, stream.crosspromotion.AdActivity.class); 158 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 159 | intent.putExtra(AdActivity.AD_DEVELOPER_ID, "8647251961827166428"); 160 | intent.putExtra(AdActivity.AD_TITLE, "More Apps from Stream"); 161 | mContext.startActivity(intent); 162 | ``` 163 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "stream.crosspromotion" 7 | minSdkVersion 15 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | } 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | implementation fileTree(include: ['*.jar'], dir: 'libs') 22 | implementation project(':crosspromotion') 23 | implementation 'androidx.appcompat:appcompat:1.0.2' 24 | implementation 'com.google.android.material:material:1.0.0' 25 | implementation 'com.android.volley:volley:1.1.1' 26 | } 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 16 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/stream/crosspromotionsample/Constants.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotionsample; 2 | 3 | public interface Constants { 4 | 5 | String SCREEN_MAIN = "Cross Promotion Demo"; 6 | 7 | } -------------------------------------------------------------------------------- /app/src/main/java/stream/crosspromotionsample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotionsample; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.MenuItem; 8 | import android.widget.FrameLayout; 9 | 10 | import androidx.appcompat.app.ActionBarDrawerToggle; 11 | import androidx.appcompat.app.AppCompatActivity; 12 | import androidx.appcompat.widget.Toolbar; 13 | import androidx.core.view.GravityCompat; 14 | import androidx.drawerlayout.widget.DrawerLayout; 15 | import androidx.fragment.app.Fragment; 16 | import androidx.fragment.app.FragmentManager; 17 | 18 | import com.google.android.material.navigation.NavigationView; 19 | 20 | import stream.crosspromotion.AdActivity; 21 | import stream.crosspromotion.AdListFragment; 22 | 23 | public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { 24 | 25 | private final String mActivity = this.getClass().getSimpleName(); 26 | String mTitleText; 27 | FrameLayout mFragmentContainer; 28 | FragmentManager mFragmentManager; 29 | AdListFragment mAdListFragment; 30 | Context mContext; 31 | Boolean restore = false; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_main); 37 | mContext = getApplication().getApplicationContext(); 38 | 39 | Toolbar toolbar = findViewById(R.id.toolbar); 40 | setSupportActionBar(toolbar); 41 | 42 | mFragmentContainer = findViewById(R.id.fragment_container); 43 | mFragmentManager = getSupportFragmentManager(); 44 | 45 | if (savedInstanceState != null) { 46 | 47 | Log.d(mActivity, "Restore"); 48 | restore = savedInstanceState.getBoolean("restore"); 49 | mTitleText = savedInstanceState.getString("mTitleText"); 50 | Fragment f = mFragmentManager.findFragmentById(R.id.fragment_container); 51 | if (f == null) { 52 | LoadFragment(mTitleText); 53 | } 54 | } else { 55 | 56 | restore = false; 57 | mTitleText = Constants.SCREEN_MAIN; 58 | LoadFragment(mTitleText); 59 | } 60 | 61 | DrawerLayout drawer = findViewById(R.id.drawer_layout); 62 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( 63 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 64 | drawer.addDrawerListener(toggle); 65 | toggle.syncState(); 66 | 67 | NavigationView navigationView = findViewById(R.id.nav_view); 68 | navigationView.setNavigationItemSelectedListener(this); 69 | } 70 | 71 | @Override 72 | public void onSaveInstanceState(Bundle outState) { 73 | 74 | super.onSaveInstanceState(outState); 75 | 76 | outState.putBoolean("restore", true); 77 | outState.putString("mTitleText", mTitleText); 78 | } 79 | 80 | @Override 81 | public void onBackPressed() { 82 | DrawerLayout drawer = findViewById(R.id.drawer_layout); 83 | if (drawer.isDrawerOpen(GravityCompat.START)) { 84 | drawer.closeDrawer(GravityCompat.START); 85 | } else { 86 | super.onBackPressed(); 87 | } 88 | } 89 | 90 | @Override 91 | public boolean onNavigationItemSelected(MenuItem item) { 92 | // Handle navigation view item clicks here. 93 | int id = item.getItemId(); 94 | 95 | if (id == R.id.nav_camera) { 96 | Intent intent = new Intent(mContext, AdActivity.class); 97 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 98 | intent.putExtra(AdActivity.AD_URL, mContext.getString(R.string.ad_url)); 99 | intent.putExtra(AdActivity.AD_TITLE, "More Apps from Stream Inc"); 100 | intent.putExtra(AdActivity.AD_DEVELOPER_ID, getString(R.string.developer_id)); 101 | mContext.startActivity(intent); 102 | } else if (id == R.id.nav_gallery) { 103 | 104 | } else if (id == R.id.nav_slideshow) { 105 | 106 | } else if (id == R.id.nav_manage) { 107 | 108 | } else if (id == R.id.nav_share) { 109 | 110 | } else if (id == R.id.nav_send) { 111 | 112 | } 113 | 114 | DrawerLayout drawer = findViewById(R.id.drawer_layout); 115 | drawer.closeDrawer(GravityCompat.START); 116 | return true; 117 | } 118 | 119 | public void LoadFragment(String screen) { 120 | Log.d("Menu", screen); 121 | //noinspection SwitchStatementWithTooFewBranches 122 | switch (screen) { 123 | case Constants.SCREEN_MAIN: 124 | mAdListFragment = AdListFragment.newInstance(); 125 | // Bundle bundle = new Bundle(); 126 | // bundle.putString(AdActivity.AD_URL, mContext.getString(R.string.ad_url)); 127 | // mAdListFragment.setArguments(bundle); 128 | mFragmentManager.beginTransaction() 129 | .replace(R.id.fragment_container, mAdListFragment, Constants.SCREEN_MAIN) 130 | .commit(); 131 | break; 132 | default: 133 | break; 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 20 | 21 | 27 | 28 | 29 | 33 | 34 | 35 | 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/nav_header_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 21 | 22 | 28 | 29 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/menu/activity_main_drawer.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 11 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 31 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #0f9d58 4 | #0c7e46 5 | #55cf86 6 | 7 | 8 | #2D2D2D 9 | #8C8C8C 10 | #757575 11 | 12 | 13 | #fdfdfd 14 | #efefef 15 | 16 | 17 | #0f9d58 18 | 19 | 20 | #FFFFFF 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/drawables.xml: -------------------------------------------------------------------------------- 1 | 2 | @android:drawable/ic_menu_camera 3 | @android:drawable/ic_menu_gallery 4 | @android:drawable/ic_menu_slideshow 5 | @android:drawable/ic_menu_manage 6 | @android:drawable/ic_menu_share 7 | @android:drawable/ic_menu_send 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Cross Promotion Demo 3 | 4 | Open navigation drawer 5 | Close navigation drawer 6 | 7 | Settings 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 20 | 21 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { url "https://maven.google.com" } 5 | google() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.4.0' 9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | maven { url "https://maven.google.com" } 17 | } 18 | } -------------------------------------------------------------------------------- /crosspromotion/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /crosspromotion/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group = 'com.github.searchy2' 5 | version = '1.8.2' 6 | 7 | android { 8 | compileSdkVersion 28 9 | 10 | defaultConfig { 11 | minSdkVersion 15 12 | targetSdkVersion 28 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(include: ['*.jar'], dir: 'libs') 24 | implementation 'androidx.appcompat:appcompat:1.0.2' 25 | implementation 'com.google.android.material:material:1.0.0' 26 | implementation 'com.android.volley:volley:1.1.1' 27 | } 28 | -------------------------------------------------------------------------------- /crosspromotion/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /crosspromotion/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/Ad.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.app.Application; 4 | import android.os.Parcel; 5 | import android.os.Parcelable; 6 | import android.util.Log; 7 | 8 | import org.json.JSONObject; 9 | 10 | public class Ad extends Application implements Parcelable { 11 | 12 | public static final Creator CREATOR = new Creator() { 13 | @Override 14 | public Ad createFromParcel(Parcel source) { 15 | return new Ad(source); 16 | } 17 | 18 | @Override 19 | public Ad[] newArray(int size) { 20 | return new Ad[size]; 21 | } 22 | }; 23 | private final String mActivity = this.getClass().getSimpleName(); 24 | public long id; 25 | public long fromUserId; 26 | public int adType; 27 | public int status; 28 | public String segment; 29 | public String location; 30 | public int deviceVersion; 31 | public int weight; 32 | public int price; 33 | public String title; 34 | public String subTitle; 35 | public String description; 36 | public String descriptionShort; 37 | public String category; 38 | public double rating; 39 | public int installs; 40 | public String version; 41 | public String developer; 42 | public String email; 43 | public String address; 44 | public String website; 45 | public String linkUrl; 46 | public String packageName; 47 | public String previewImageUrl; 48 | public String imageUrl; 49 | public String previewVideoImageUrl; 50 | public String videoUrl; 51 | public String text1; 52 | public String text2; 53 | public String text3; 54 | public int number1; 55 | public int number2; 56 | public int number3; 57 | public int createAt; 58 | public int updateAt; 59 | public int startAt; 60 | public int endAt; 61 | public int removeAt; 62 | 63 | public Ad() { 64 | 65 | } 66 | 67 | public Ad(JSONObject jsonData) { 68 | try { 69 | this.setId(jsonData.getLong("id")); 70 | this.setFromUserId(jsonData.getLong("fromUserId")); 71 | this.setAdType(jsonData.getInt("adType")); 72 | this.setStatus(jsonData.getInt("status")); 73 | this.setSegment(jsonData.getString("segment")); 74 | this.setLocation(jsonData.getString("location")); 75 | this.setDeviceVersion(jsonData.getInt("deviceVersion")); 76 | this.setWeight(jsonData.getInt("weight")); 77 | this.setPrice(jsonData.getInt("price")); 78 | this.setTitle(jsonData.getString("title")); 79 | this.setSubTitle(jsonData.getString("subtitle")); 80 | this.setDescription(jsonData.getString("description")); 81 | this.setDescriptionShort(jsonData.getString("descriptionShort")); 82 | this.setCategory(jsonData.getString("category")); 83 | this.setRating(jsonData.getDouble("rating")); 84 | this.setInstalls(jsonData.getInt("installs")); 85 | this.setVersion(jsonData.getString("version")); 86 | this.setDeveloper(jsonData.getString("developer")); 87 | this.setEmail(jsonData.getString("email")); 88 | this.setAddress(jsonData.getString("address")); 89 | this.setWebsite(jsonData.getString("website")); 90 | this.setLinkUrl(jsonData.getString("linkUrl")); 91 | this.setMyPackageName(jsonData.getString("packageName")); 92 | this.setPreviewImageUrl(jsonData.getString("previewImgUrl")); 93 | this.setImageUrl(jsonData.getString("imgUrl")); 94 | this.setPreviewVideoImageUrl(jsonData.getString("previewVideoImgUrl")); 95 | this.setVideoUrl(jsonData.getString("videoUrl")); 96 | this.setText1(jsonData.getString("text1")); 97 | this.setText2(jsonData.getString("text2")); 98 | this.setText3(jsonData.getString("text3")); 99 | this.setNumber1(jsonData.getInt("number1")); 100 | this.setNumber2(jsonData.getInt("number2")); 101 | this.setNumber3(jsonData.getInt("number3")); 102 | this.setCreateAt(jsonData.getInt("createAt")); 103 | this.setUpdateAt(jsonData.getInt("updateAt")); 104 | this.setStartAt(jsonData.getInt("startAt")); 105 | this.setEndAt(jsonData.getInt("endAt")); 106 | this.setRemoveAt(jsonData.getInt("removeAt")); 107 | } catch (Throwable t) { 108 | 109 | Log.e(mActivity, "Error JSON: \"" + jsonData.toString() + "\""); 110 | 111 | } finally { 112 | 113 | Log.d(mActivity, "JSON: " + jsonData.toString()); 114 | } 115 | } 116 | 117 | protected Ad(Parcel in) { 118 | this.id = in.readLong(); 119 | this.fromUserId = in.readLong(); 120 | this.adType = in.readInt(); 121 | this.status = in.readInt(); 122 | this.segment = in.readString(); 123 | this.location = in.readString(); 124 | this.deviceVersion = in.readInt(); 125 | this.weight = in.readInt(); 126 | this.price = in.readInt(); 127 | this.title = in.readString(); 128 | this.subTitle = in.readString(); 129 | this.description = in.readString(); 130 | this.descriptionShort = in.readString(); 131 | this.category = in.readString(); 132 | this.rating = in.readDouble(); 133 | this.installs = in.readInt(); 134 | this.version = in.readString(); 135 | this.developer = in.readString(); 136 | this.email = in.readString(); 137 | this.address = in.readString(); 138 | this.website = in.readString(); 139 | this.linkUrl = in.readString(); 140 | this.packageName = in.readString(); 141 | this.previewImageUrl = in.readString(); 142 | this.imageUrl = in.readString(); 143 | this.previewVideoImageUrl = in.readString(); 144 | this.videoUrl = in.readString(); 145 | this.text1 = in.readString(); 146 | this.text2 = in.readString(); 147 | this.text3 = in.readString(); 148 | this.number1 = in.readInt(); 149 | this.number2 = in.readInt(); 150 | this.number3 = in.readInt(); 151 | this.createAt = in.readInt(); 152 | this.updateAt = in.readInt(); 153 | this.startAt = in.readInt(); 154 | this.endAt = in.readInt(); 155 | this.removeAt = in.readInt(); 156 | } 157 | 158 | public long getId() { 159 | return id; 160 | } 161 | 162 | public void setId(long id) { 163 | this.id = id; 164 | } 165 | 166 | public long getFromUserId() { 167 | return fromUserId; 168 | } 169 | 170 | public void setFromUserId(long fromUserId) { 171 | this.fromUserId = fromUserId; 172 | } 173 | 174 | public int getAdType() { 175 | return adType; 176 | } 177 | 178 | public void setAdType(int adType) { 179 | this.adType = adType; 180 | } 181 | 182 | public int getStatus() { 183 | return status; 184 | } 185 | 186 | public void setStatus(int status) { 187 | this.status = status; 188 | } 189 | 190 | public String getSegment() { 191 | return segment; 192 | } 193 | 194 | public void setSegment(String segment) { 195 | this.segment = segment; 196 | } 197 | 198 | public String getLocation() { 199 | return location; 200 | } 201 | 202 | public void setLocation(String location) { 203 | this.location = location; 204 | } 205 | 206 | public int getDeviceVersion() { 207 | return deviceVersion; 208 | } 209 | 210 | public void setDeviceVersion(int deviceVersion) { 211 | this.deviceVersion = deviceVersion; 212 | } 213 | 214 | public int getWeight() { 215 | return weight; 216 | } 217 | 218 | public void setWeight(int weight) { 219 | this.weight = weight; 220 | } 221 | 222 | public int getPrice() { 223 | return price; 224 | } 225 | 226 | public void setPrice(int price) { 227 | this.price = price; 228 | } 229 | 230 | public String getTitle() { 231 | return title; 232 | } 233 | 234 | public void setTitle(String title) { 235 | this.title = title; 236 | } 237 | 238 | public String getSubTitle() { 239 | return subTitle; 240 | } 241 | 242 | public void setSubTitle(String subTitle) { 243 | this.subTitle = subTitle; 244 | } 245 | 246 | public String getDescription() { 247 | return description; 248 | } 249 | 250 | public void setDescription(String description) { 251 | this.description = description; 252 | } 253 | 254 | public String getDescriptionShort() { 255 | return descriptionShort; 256 | } 257 | 258 | public void setDescriptionShort(String descriptionShort) { 259 | this.descriptionShort = descriptionShort; 260 | } 261 | 262 | public String getCategory() { 263 | return category; 264 | } 265 | 266 | public void setCategory(String category) { 267 | this.category = category; 268 | } 269 | 270 | public double getRating() { 271 | return rating; 272 | } 273 | 274 | public void setRating(double rating) { 275 | this.rating = rating; 276 | } 277 | 278 | public int getInstalls() { 279 | return installs; 280 | } 281 | 282 | public void setInstalls(int installs) { 283 | this.installs = installs; 284 | } 285 | 286 | public String getVersion() { 287 | return version; 288 | } 289 | 290 | public void setVersion(String version) { 291 | this.version = version; 292 | } 293 | 294 | public String getDeveloper() { 295 | return developer; 296 | } 297 | 298 | public void setDeveloper(String developer) { 299 | this.developer = developer; 300 | } 301 | 302 | public String getEmail() { 303 | return email; 304 | } 305 | 306 | public void setEmail(String email) { 307 | this.email = email; 308 | } 309 | 310 | public String getAddress() { 311 | return address; 312 | } 313 | 314 | public void setAddress(String address) { 315 | this.address = address; 316 | } 317 | 318 | public String getWebsite() { 319 | return website; 320 | } 321 | 322 | public void setWebsite(String website) { 323 | this.website = website; 324 | } 325 | 326 | public String getLinkUrl() { 327 | return linkUrl; 328 | } 329 | 330 | public void setLinkUrl(String linkUrl) { 331 | this.linkUrl = linkUrl; 332 | } 333 | 334 | public String getMyPackageName() { 335 | return packageName; 336 | } 337 | 338 | public void setMyPackageName(String packageName) { 339 | this.packageName = packageName; 340 | } 341 | 342 | public String getPreviewImageUrl() { 343 | return previewImageUrl; 344 | } 345 | 346 | public void setPreviewImageUrl(String previewImageUrl) { 347 | this.previewImageUrl = previewImageUrl; 348 | } 349 | 350 | public String getImageUrl() { 351 | return imageUrl; 352 | } 353 | 354 | public void setImageUrl(String imageUrl) { 355 | this.imageUrl = imageUrl; 356 | } 357 | 358 | public String getPreviewVideoImageUrl() { 359 | return previewVideoImageUrl; 360 | } 361 | 362 | public void setPreviewVideoImageUrl(String previewVideoImageUrl) { 363 | this.previewVideoImageUrl = previewVideoImageUrl; 364 | } 365 | 366 | public String getVideoUrl() { 367 | return videoUrl; 368 | } 369 | 370 | public void setVideoUrl(String videoUrl) { 371 | this.videoUrl = videoUrl; 372 | } 373 | 374 | public String getText1() { 375 | return text1; 376 | } 377 | 378 | public void setText1(String text1) { 379 | this.text1 = text1; 380 | } 381 | 382 | public String getText2() { 383 | return text2; 384 | } 385 | 386 | public void setText2(String text2) { 387 | this.text2 = text2; 388 | } 389 | 390 | public String getText3() { 391 | return text3; 392 | } 393 | 394 | public void setText3(String text3) { 395 | this.text3 = text3; 396 | } 397 | 398 | public int getNumber1() { 399 | return number1; 400 | } 401 | 402 | public void setNumber1(int number1) { 403 | this.number1 = number1; 404 | } 405 | 406 | public int getNumber2() { 407 | return number2; 408 | } 409 | 410 | public void setNumber2(int number2) { 411 | this.number2 = number2; 412 | } 413 | 414 | public int getNumber3() { 415 | return number3; 416 | } 417 | 418 | public void setNumber3(int number3) { 419 | this.number3 = number3; 420 | } 421 | 422 | public int getCreateAt() { 423 | return createAt; 424 | } 425 | 426 | public void setCreateAt(int createAt) { 427 | this.createAt = createAt; 428 | } 429 | 430 | public int getUpdateAt() { 431 | return updateAt; 432 | } 433 | 434 | public void setUpdateAt(int updateAt) { 435 | this.updateAt = updateAt; 436 | } 437 | 438 | public int getStartAt() { 439 | return startAt; 440 | } 441 | 442 | public void setStartAt(int startAt) { 443 | this.startAt = startAt; 444 | } 445 | 446 | public int getEndAt() { 447 | return endAt; 448 | } 449 | 450 | public void setEndAt(int endAt) { 451 | this.endAt = endAt; 452 | } 453 | 454 | public int getRemoveAt() { 455 | return removeAt; 456 | } 457 | 458 | public void setRemoveAt(int removeAt) { 459 | this.removeAt = removeAt; 460 | } 461 | 462 | @Override 463 | public int describeContents() { 464 | return 0; 465 | } 466 | 467 | @Override 468 | public void writeToParcel(Parcel dest, int flags) { 469 | dest.writeLong(this.id); 470 | dest.writeLong(this.fromUserId); 471 | dest.writeInt(this.adType); 472 | dest.writeInt(this.status); 473 | dest.writeString(this.segment); 474 | dest.writeString(this.location); 475 | dest.writeInt(this.deviceVersion); 476 | dest.writeInt(this.weight); 477 | dest.writeInt(this.price); 478 | dest.writeString(this.title); 479 | dest.writeString(this.subTitle); 480 | dest.writeString(this.description); 481 | dest.writeString(this.descriptionShort); 482 | dest.writeString(this.category); 483 | dest.writeDouble(this.rating); 484 | dest.writeInt(this.installs); 485 | dest.writeString(this.version); 486 | dest.writeString(this.developer); 487 | dest.writeString(this.email); 488 | dest.writeString(this.address); 489 | dest.writeString(this.website); 490 | dest.writeString(this.linkUrl); 491 | dest.writeString(this.packageName); 492 | dest.writeString(this.previewImageUrl); 493 | dest.writeString(this.imageUrl); 494 | dest.writeString(this.previewVideoImageUrl); 495 | dest.writeString(this.videoUrl); 496 | dest.writeString(this.text1); 497 | dest.writeString(this.text2); 498 | dest.writeString(this.text3); 499 | dest.writeInt(this.number1); 500 | dest.writeInt(this.number2); 501 | dest.writeInt(this.number3); 502 | dest.writeInt(this.createAt); 503 | dest.writeInt(this.updateAt); 504 | dest.writeInt(this.startAt); 505 | dest.writeInt(this.endAt); 506 | dest.writeInt(this.removeAt); 507 | } 508 | } 509 | -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/AdActivity.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | import android.view.Menu; 7 | import android.view.MenuItem; 8 | import android.widget.FrameLayout; 9 | 10 | import androidx.appcompat.app.AppCompatActivity; 11 | import androidx.appcompat.widget.Toolbar; 12 | import androidx.fragment.app.Fragment; 13 | import androidx.fragment.app.FragmentManager; 14 | 15 | public class AdActivity extends AppCompatActivity { 16 | 17 | public static String AD_URL = "AD_URL"; 18 | public static String AD_TITLE = "AD_TITLE"; 19 | public static String AD_DEVELOPER_ID = "AD_DEVELOPER_ID"; 20 | private final String mActivity = getClass().getSimpleName(); 21 | 22 | String mScreen; //Active fragment ID. 23 | String adUrl; //Ad server URL. 24 | String title; //ActionBar title. 25 | String developerUrl; //Developer page URL. 26 | 27 | FrameLayout mFragmentContainer; 28 | FragmentManager mFragmentManager; 29 | AdListFragment mAdListFragment; 30 | 31 | Context mContext; 32 | 33 | Boolean restore = false; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_acp); 39 | mContext = getApplication().getApplicationContext(); 40 | 41 | getData(); 42 | 43 | AdActivity.this.setTitle(title); 44 | Toolbar toolbar = findViewById(R.id.toolbar); 45 | setSupportActionBar(toolbar); 46 | if (getSupportActionBar() != null) { 47 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 48 | } 49 | 50 | mFragmentContainer = findViewById(R.id.fragment_adcontainer); 51 | mFragmentManager = getSupportFragmentManager(); 52 | 53 | if (savedInstanceState != null) { 54 | Log.d(mActivity, "Restore"); 55 | restore = savedInstanceState.getBoolean("restore"); 56 | mScreen = savedInstanceState.getString("screen"); 57 | Fragment f = mFragmentManager.findFragmentById(R.id.fragment_adcontainer); 58 | if (f == null) { 59 | LoadFragment(mScreen); 60 | } 61 | } else { 62 | restore = false; 63 | mScreen = Constants.SCREEN_MAIN; 64 | LoadFragment(mScreen); 65 | } 66 | } 67 | 68 | @Override 69 | public void onSaveInstanceState(Bundle outState) { 70 | 71 | super.onSaveInstanceState(outState); 72 | 73 | outState.putBoolean("restore", true); 74 | outState.putString("screen", mScreen); 75 | } 76 | 77 | @Override 78 | public boolean onCreateOptionsMenu(Menu menu) { 79 | 80 | getMenuInflater().inflate(R.menu.menu_main, menu); 81 | MenuItem item = menu.findItem(R.id.menu_store); 82 | if (developerUrl != null) { 83 | item.setVisible(true); 84 | } 85 | 86 | return true; 87 | } 88 | 89 | @Override 90 | public boolean onOptionsItemSelected(MenuItem item) { 91 | 92 | int id = item.getItemId(); 93 | 94 | if (id == android.R.id.home) { 95 | onBackPressed(); 96 | } else if (id == R.id.menu_store) { 97 | Utils.OpenDeveloperUrl(mContext, developerUrl); 98 | } 99 | 100 | return super.onOptionsItemSelected(item); 101 | } 102 | 103 | public void LoadFragment(String screen) { 104 | Log.d("Menu", screen); 105 | //noinspection SwitchStatementWithTooFewBranches 106 | switch (screen) { 107 | case Constants.SCREEN_MAIN: 108 | mAdListFragment = AdListFragment.newInstance(); 109 | Bundle bundle = new Bundle(); 110 | bundle.putString(AD_URL, adUrl); 111 | mAdListFragment.setArguments(bundle); 112 | mFragmentManager.beginTransaction() 113 | .replace(R.id.fragment_adcontainer, mAdListFragment, Constants.SCREEN_MAIN) 114 | .commit(); 115 | break; 116 | default: 117 | break; 118 | } 119 | } 120 | 121 | /** 122 | * Get data passed by intent. 123 | */ 124 | private void getData() { 125 | Log.d("AdActivity", "Get Data"); 126 | if (getIntent() != null) { 127 | //Get ad server URL. 128 | if (getIntent().getStringExtra(AD_URL) != null) { 129 | adUrl = getIntent().getStringExtra(AD_URL); 130 | } 131 | //Get ActionBar title. 132 | if (getIntent().getStringExtra(AD_TITLE) != null) { 133 | title = getIntent().getStringExtra(AD_TITLE); 134 | } else { 135 | title = getString(R.string.title); 136 | } 137 | //Get developer page URL. 138 | if (getIntent().getStringExtra(AD_DEVELOPER_ID) != null) { 139 | developerUrl = getIntent().getStringExtra(AD_DEVELOPER_ID); 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/AdListFragment.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.pm.ApplicationInfo; 6 | import android.content.pm.PackageManager; 7 | import android.net.Uri; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | import android.util.Log; 11 | import android.view.LayoutInflater; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.widget.ImageView; 15 | import android.widget.LinearLayout; 16 | import android.widget.TextView; 17 | 18 | import androidx.fragment.app.Fragment; 19 | import androidx.recyclerview.widget.LinearLayoutManager; 20 | import androidx.recyclerview.widget.RecyclerView; 21 | 22 | import com.android.volley.Request; 23 | import com.android.volley.Response; 24 | import com.android.volley.VolleyError; 25 | import com.android.volley.toolbox.ImageLoader; 26 | 27 | import org.json.JSONArray; 28 | import org.json.JSONException; 29 | import org.json.JSONObject; 30 | 31 | import java.util.ArrayList; 32 | import java.util.HashMap; 33 | import java.util.Map; 34 | 35 | public class AdListFragment extends Fragment { 36 | 37 | private static final String STATE_LIST = "State Adapter Data"; 38 | final String mActivity = this.getClass().getSimpleName(); 39 | 40 | String adUrl = ""; //Ad server URL. 41 | 42 | TextView mMessage; 43 | RecyclerView mRecyclerView; 44 | MainAdapter mAdapter; 45 | LinearLayoutManager mLayoutManager; 46 | ArrayList mList; 47 | DatabaseHelper dbHelper; 48 | 49 | Context mContext; 50 | 51 | Boolean restore = false; 52 | 53 | public AdListFragment() { 54 | } 55 | 56 | public static AdListFragment newInstance() { 57 | return new AdListFragment(); 58 | } 59 | 60 | @Override 61 | public void onCreate(Bundle savedInstanceState) { 62 | 63 | super.onCreate(savedInstanceState); 64 | mContext = getActivity().getApplicationContext(); 65 | dbHelper = DatabaseHelper.getInstance(mContext); 66 | 67 | getData(); 68 | 69 | if (savedInstanceState != null) { 70 | restore = savedInstanceState.getBoolean("restore"); 71 | mList = savedInstanceState.getParcelableArrayList(STATE_LIST); 72 | mAdapter = new MainAdapter(getActivity(), mList); 73 | adUrl = savedInstanceState.getString("adUrl"); 74 | } else { 75 | restore = false; 76 | mList = new ArrayList<>(); 77 | mAdapter = new MainAdapter(getActivity(), mList); 78 | adUrl = getAdUrl(); 79 | } 80 | } 81 | 82 | @Override 83 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 84 | 85 | View rootView = inflater.inflate(R.layout.fragment_acp, container, false); 86 | 87 | mMessage = rootView.findViewById(R.id.message); 88 | mMessage.setOnClickListener(new View.OnClickListener() { 89 | @Override 90 | public void onClick(View view) { 91 | GetItems(); 92 | } 93 | }); 94 | 95 | mLayoutManager = new LinearLayoutManager(getActivity()); 96 | mRecyclerView = rootView.findViewById(R.id.recyclerview); 97 | mRecyclerView.setLayoutManager(mLayoutManager); 98 | mRecyclerView.setAdapter(mAdapter); 99 | 100 | if (mList.size() == 0) { 101 | showMessage(); 102 | } else { 103 | hideMessage(); 104 | } 105 | 106 | if (!restore) { 107 | LoadItems(); 108 | } 109 | 110 | return rootView; 111 | } 112 | 113 | @Override 114 | public void onSaveInstanceState(Bundle outState) { 115 | 116 | super.onSaveInstanceState(outState); 117 | 118 | outState.putBoolean("restore", true); 119 | outState.putParcelableArrayList(STATE_LIST, mList); 120 | outState.putString("adUrl", adUrl); 121 | } 122 | 123 | @Override 124 | public void onResume() { 125 | super.onResume(); 126 | 127 | //Refresh items from server if they have been updated. 128 | GetItems(); 129 | } 130 | 131 | public void GetItems() { 132 | 133 | Log.d(mActivity, "GetItems"); 134 | 135 | if (adUrl != null) { 136 | CustomRequest jsonReq = new CustomRequest(Request.Method.POST, adUrl + Constants.METHOD_ADS_GET, null, 137 | new Response.Listener() { 138 | @Override 139 | public void onResponse(JSONObject response) { 140 | 141 | Log.d(mActivity, "Ads JSON: " + response.toString()); 142 | 143 | if (!isAdded() || getActivity() == null) { 144 | 145 | Log.e(mActivity, "Fragment Not Added to Activity"); 146 | return; 147 | } 148 | 149 | try { 150 | if (!response.getBoolean("error")) { 151 | 152 | if (response.has("items")) { 153 | 154 | JSONArray itemsArray = response.getJSONArray("items"); 155 | if (itemsArray.length() > 0) { 156 | dbHelper.AddAdsBatch(itemsArray); 157 | LoadItems(); 158 | } 159 | } 160 | } 161 | } catch (JSONException e) { 162 | 163 | e.printStackTrace(); 164 | 165 | } 166 | } 167 | }, new Response.ErrorListener() { 168 | @Override 169 | public void onErrorResponse(VolleyError error) { 170 | 171 | if (!isAdded() || getActivity() == null) { 172 | 173 | Log.e(mActivity, "Fragment Not Added to Activity"); 174 | return; 175 | } 176 | 177 | Log.e(mActivity, "Error: " + error.toString()); 178 | FinishLoad(); 179 | } 180 | }) { 181 | @Override 182 | protected Map getParams() { 183 | Map params = new HashMap(); 184 | params.put("clientId", Constants.CLIENT_ID); 185 | params.put("updateAt", Integer.toString(dbHelper.GetAdsLatestUpdate(dbHelper.GetMaxAdID(), Constants.AD_LIMIT))); 186 | 187 | return params; 188 | } 189 | }; 190 | 191 | VolleySingleton.getInstance(mContext).addToRequestQueue(jsonReq); 192 | } 193 | } 194 | 195 | public void LoadItems() { 196 | 197 | ArrayList items; 198 | mList.clear(); 199 | if (mList != null && !mList.isEmpty()) { 200 | items = dbHelper.GetAds(Constants.AD_LIMIT); 201 | } else { 202 | items = dbHelper.GetAds(Constants.AD_LIMIT); 203 | } 204 | mList.addAll(items); 205 | 206 | FinishLoad(); 207 | } 208 | 209 | public void FinishLoad() { 210 | if (mAdapter.getItemCount() == 0) { 211 | if (getActivity() != null && this.isAdded()) { 212 | showMessage(); 213 | } 214 | } else { 215 | hideMessage(); 216 | } 217 | mAdapter.notifyDataSetChanged(); 218 | } 219 | 220 | 221 | public void showMessage() { 222 | 223 | mMessage.setVisibility(View.VISIBLE); 224 | } 225 | 226 | public void hideMessage() { 227 | 228 | mMessage.setVisibility(View.GONE); 229 | } 230 | 231 | /** 232 | * Set Ad URL. 233 | *

234 | * Set the ad server URL to the user passed URL argument. 235 | * If no argument is passed, look for the CustomAds meta data value in the manifest. 236 | * Defaults to ad server URL in string values. 237 | */ 238 | private String getAdUrl() { 239 | if (adUrl.equals("")) { 240 | try { 241 | ApplicationInfo ai = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA); 242 | Object value = ai.metaData.get("CustomAds"); 243 | return value != null ? value.toString() : ""; 244 | } catch (PackageManager.NameNotFoundException e) { 245 | e.printStackTrace(); 246 | return mContext.getString(R.string.ad_url); 247 | } catch (NullPointerException e) { 248 | e.printStackTrace(); 249 | return mContext.getString(R.string.ad_url); 250 | } 251 | } 252 | 253 | return adUrl; 254 | } 255 | 256 | /** 257 | * Get data passed by intent. 258 | */ 259 | private void getData() { 260 | if (getArguments() != null) { 261 | Bundle bundle = getArguments(); 262 | //Get ad server URL. 263 | if (bundle.getString(AdActivity.AD_URL) != null) { 264 | adUrl = bundle.getString(AdActivity.AD_URL); 265 | } 266 | } 267 | } 268 | 269 | public class MainAdapter extends RecyclerView.Adapter { 270 | 271 | public final String mActivity = this.getClass().getSimpleName(); 272 | Context mContext; 273 | ArrayList mList; 274 | 275 | public MainAdapter(Context context, ArrayList list) { 276 | mContext = context; 277 | mList = list; 278 | } 279 | 280 | @Override 281 | public MainAdapter.MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 282 | View itemView; 283 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main, parent, false); 284 | return new MainViewHolder(itemView); 285 | } 286 | 287 | @Override 288 | public void onBindViewHolder(MainViewHolder holder, int position) { 289 | Ad item = mList.get(position); 290 | holder.setItem(item); 291 | } 292 | 293 | @Override 294 | public int getItemCount() { 295 | return mList.size(); 296 | } 297 | 298 | public Ad getItem(int position) { 299 | return mList.get(position); 300 | } 301 | 302 | public class MainViewHolder extends RecyclerView.ViewHolder { 303 | 304 | private final String mActivity = this.getClass().getSimpleName(); 305 | View.OnClickListener itemClick; 306 | Context mContext; 307 | private LinearLayout mLayout; 308 | private ImageView mImage; 309 | private TextView mRating; 310 | private TextView mTitle; 311 | private TextView mDescription; 312 | private TextView mPrice; 313 | private TextView mBtnInstall; 314 | 315 | public MainViewHolder(View itemView) { 316 | 317 | super(itemView); 318 | 319 | mLayout = itemView.findViewById(R.id.container); 320 | mImage = itemView.findViewById(R.id.image); 321 | mRating = itemView.findViewById(R.id.rating); 322 | mTitle = itemView.findViewById(R.id.title); 323 | mDescription = itemView.findViewById(R.id.description); 324 | mPrice = itemView.findViewById(R.id.price); 325 | mBtnInstall = itemView.findViewById(R.id.btn_install); 326 | 327 | mContext = itemView.getContext(); 328 | } 329 | 330 | public void setItem(final Ad item) { 331 | 332 | itemClick = new View.OnClickListener() { 333 | @Override 334 | public void onClick(View view) { 335 | 336 | Intent intent = new Intent(Intent.ACTION_VIEW); 337 | String packageName = item.getMyPackageName(); 338 | if (Utils.isAppInstalled(mContext, "com.android.vending")) { 339 | intent.setData(Uri.parse("market://details?id=" + packageName)); 340 | try { 341 | mContext.startActivity(intent); 342 | } catch (android.content.ActivityNotFoundException ex) { 343 | intent.setData(Uri.parse(String.format("https://play.google.com/store/apps/details?id=%s", packageName))); 344 | mContext.startActivity(intent); 345 | } 346 | } else { 347 | intent.setData(Uri.parse(String.format("https://play.google.com/store/apps/details?id=%s", packageName))); 348 | mContext.startActivity(intent); 349 | } 350 | } 351 | }; 352 | mLayout.setOnClickListener(itemClick); 353 | mImage.setOnClickListener(itemClick); 354 | mBtnInstall.setOnClickListener(itemClick); 355 | 356 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 357 | VolleySingleton.getInstance(mContext).getImageLoader().get(item.getPreviewImageUrl(), ImageLoader.getImageListener(mImage, R.drawable.icon_apk_circle, R.drawable.icon_apk_circle)); 358 | } else { 359 | VolleySingleton.getInstance(mContext).getImageLoader().get(item.getPreviewImageUrl(), ImageLoader.getImageListener(mImage, R.drawable.icon_apk_circle_old, R.drawable.icon_apk_circle_old)); 360 | } 361 | mRating.setText(Double.toString(item.getRating())); 362 | 363 | mTitle.setText(item.getTitle()); 364 | mDescription.setText(item.getSubTitle()); 365 | 366 | if (item.getPrice() == 0) { 367 | mPrice.setText("FREE"); 368 | } else { 369 | mPrice.setText("$" + item.getPrice() / 100); 370 | } 371 | } 372 | } 373 | } 374 | } 375 | 376 | -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/Constants.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | public interface Constants { 4 | 5 | String SCREEN_MAIN = "Cross Promotion Demo"; 6 | 7 | String CLIENT_ID = "1"; // Client ID | For identify the application | Example: 12567 8 | 9 | String METHOD_ADS_GET = "ads.get.php"; 10 | 11 | int AD_LIMIT = 20; 12 | } -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/CustomRequest.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import com.android.volley.NetworkResponse; 4 | import com.android.volley.ParseError; 5 | import com.android.volley.Request; 6 | import com.android.volley.Response; 7 | import com.android.volley.Response.ErrorListener; 8 | import com.android.volley.Response.Listener; 9 | import com.android.volley.toolbox.HttpHeaderParser; 10 | 11 | import org.json.JSONException; 12 | import org.json.JSONObject; 13 | 14 | import java.io.UnsupportedEncodingException; 15 | import java.util.Map; 16 | 17 | public class CustomRequest extends Request { 18 | 19 | private Listener listener; 20 | private Map params; 21 | 22 | public CustomRequest(String url, Map params, 23 | Listener reponseListener, ErrorListener errorListener) { 24 | super(Method.GET, url, errorListener); 25 | this.listener = reponseListener; 26 | this.params = params; 27 | } 28 | 29 | public CustomRequest(int method, String url, Map params, 30 | Listener reponseListener, ErrorListener errorListener) { 31 | super(method, url, errorListener); 32 | this.listener = reponseListener; 33 | this.params = params; 34 | } 35 | 36 | protected Map getParams() 37 | throws com.android.volley.AuthFailureError { 38 | return params; 39 | } 40 | 41 | @Override 42 | protected Response parseNetworkResponse(NetworkResponse response) { 43 | try { 44 | String jsonString = new String(response.data, 45 | HttpHeaderParser.parseCharset(response.headers)); 46 | return Response.success(new JSONObject(jsonString), 47 | HttpHeaderParser.parseCacheHeaders(response)); 48 | } catch (UnsupportedEncodingException e) { 49 | return Response.error(new ParseError(e)); 50 | } catch (JSONException je) { 51 | return Response.error(new ParseError(je)); 52 | } 53 | } 54 | 55 | @Override 56 | protected void deliverResponse(JSONObject response) { 57 | listener.onResponse(response); 58 | } 59 | } -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/DatabaseHelper.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.database.sqlite.SQLiteOpenHelper; 8 | import android.util.Log; 9 | 10 | import org.json.JSONArray; 11 | import org.json.JSONObject; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Date; 15 | 16 | public class DatabaseHelper extends SQLiteOpenHelper { 17 | 18 | public static final int DBVersion = 1; 19 | public static final String DBName = "CrossPromotionDB"; 20 | 21 | public static final String TABLE_ADS = "ads"; 22 | public static final String KEY_ID = "_id"; 23 | public static final String KEY_ORIGINALID = "originalid"; 24 | public static final String KEY_FROMID = "fromid"; 25 | public static final String KEY_ADTYPE = "adtype"; 26 | public static final String KEY_STATUS = "status"; 27 | public static final String KEY_SEGMENT = "segment"; 28 | public static final String KEY_LOCATION = "location"; 29 | public static final String KEY_DEVICEVERSION = "deviceversion"; 30 | public static final String KEY_WEIGHT = "weight"; 31 | public static final String KEY_PRICE = "price"; 32 | public static final String KEY_TITLE = "title"; 33 | public static final String KEY_SUBTITLE = "subtitle"; 34 | public static final String KEY_DESCRIPTION = "description"; 35 | public static final String KEY_DESCRIPTIONSHORT = "descriptionshort"; 36 | public static final String KEY_CATEGORY = "category"; 37 | public static final String KEY_RATING = "rating"; 38 | public static final String KEY_INSTALLS = "installs"; 39 | public static final String KEY_VERSION = "version"; 40 | public static final String KEY_DEVELOPER = "developer"; 41 | public static final String KEY_EMAIL = "email"; 42 | public static final String KEY_ADDRESS = "address"; 43 | public static final String KEY_WEBSITE = "website"; 44 | public static final String KEY_LINKURL = "linkurl"; 45 | public static final String KEY_PACKAGENAME = "packagename"; 46 | public static final String KEY_PREVIEWIMAGEURL = "previewimageurl"; 47 | public static final String KEY_IMAGEURL = "imageurl"; 48 | public static final String KEY_PREVIEWVIDEOIMAGEURL = "previewvideoimageurl"; 49 | public static final String KEY_VIDEOURL = "videourl"; 50 | public static final String KEY_TEXT1 = "text1"; 51 | public static final String KEY_TEXT2 = "text2"; 52 | public static final String KEY_TEXT3 = "text3"; 53 | public static final String KEY_NUMBER1 = "number1"; 54 | public static final String KEY_NUMBER2 = "number2"; 55 | public static final String KEY_NUMBER3 = "number3"; 56 | public static final String KEY_CREATEAT = "createat"; 57 | public static final String KEY_UPDATEAT = "updateat"; 58 | public static final String KEY_STARTAT = "startat"; 59 | public static final String KEY_ENDAT = "endat"; 60 | public static final String KEY_REMOVEAT = "removeat"; 61 | 62 | public static final String TABLE_ANALYTICS = "analytics"; 63 | // public static final String KEY_ID = "_id"; 64 | public static final String KEY_ANALYTICSTYPE = "analyticstype"; 65 | public static final String KEY_STATID = "statid"; 66 | public static final String KEY_STATINT = "statint"; 67 | public static final String KEY_STATTEXT = "stattext"; 68 | // public static final String KEY_CREATEAT = "createat"; 69 | public static final String KEY_UPLOADED = "uploaded"; 70 | 71 | private static DatabaseHelper mInstance = null; 72 | public final String mActivity = this.getClass().getSimpleName(); 73 | public Context mContext; 74 | 75 | public DatabaseHelper(Context context) { 76 | super(context, DBName, null, DBVersion); 77 | mContext = context; 78 | } 79 | 80 | public static DatabaseHelper getInstance(Context context) { 81 | 82 | if (mInstance == null) { 83 | mInstance = new DatabaseHelper(context); 84 | } 85 | return mInstance; 86 | } 87 | 88 | @Override 89 | public void onCreate(SQLiteDatabase db) { 90 | //Table Query. 91 | String adsTable = "CREATE TABLE IF NOT EXISTS ads (_id INTEGER PRIMARY KEY AUTOINCREMENT, originalid INTEGER, fromid INTEGER, adtype INTEGER, status INTEGER, " + 92 | "segment TEXT, location TEXT, deviceversion INTEGER, weight INTEGER, price INTEGER, title TEXT, subtitle TEXT, description TEXT, descriptionshort TEXT, " + 93 | "category TEXT, rating INTEGER, installs INTEGER, version TEXT, developer TEXT, email TEXT, address TEXT, website TEXT, linkurl TEXT, packagename TEXT, " + 94 | "previewimageurl TEXT, imageurl TEXT, previewvideoimageurl TEXT, videourl TEXT, text1 TEXT, text2 TEXT, text3 TEXT, number1 INTEGER, number2 INTEGER, " + 95 | "number3 INTEGER, createat INTEGER DEFAULT 0, updateat INTEGER DEFAULT 0, startat INTEGER DEFAULT 0, endat INTEGER DEFAULT 0, removeat INTEGER DEFAULT 0);"; 96 | String analyticsTable = "CREATE TABLE IF NOT EXISTS analytics (_id INTEGER PRIMARY KEY AUTOINCREMENT, analyticstype INTEGER, statid INTEGER, statint INTEGER, stattext TEXT, createat INTEGER DEFAULT 0, uploaded INTEGER DEFAULT 0);"; 97 | 98 | //Execute Query 99 | db.execSQL(adsTable); 100 | Log.d("SQLite", "Tables created"); 101 | } 102 | 103 | @Override 104 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 105 | 106 | db.execSQL("DROP TABLE IF EXISTS " + TABLE_ADS); 107 | onCreate(db); 108 | } 109 | 110 | public void ResetDatabase() { 111 | 112 | SQLiteDatabase db = this.getWritableDatabase(); 113 | db.execSQL("DROP TABLE IF EXISTS " + TABLE_ADS); 114 | onCreate(db); 115 | 116 | db.close(); 117 | } 118 | 119 | public void InitializeDatabase() { 120 | ResetDatabase(); 121 | SQLiteDatabase db = this.getWritableDatabase(); 122 | onCreate(db); 123 | db.close(); 124 | } 125 | 126 | public ArrayList GetAds(Integer limit) { 127 | Log.d("Package Name", mContext.getPackageName()); 128 | ArrayList itemList = new ArrayList<>(); 129 | Date currentDate = new Date(); 130 | Long currentTime = currentDate.getTime() / 1000; 131 | SQLiteDatabase db = this.getReadableDatabase(); 132 | Cursor c = db.query(TABLE_ADS, null, KEY_REMOVEAT + "=0 AND " + KEY_STARTAT + "?", new String[]{Long.toString(currentTime), Long.toString(currentTime)}, null, null, KEY_WEIGHT + " DESC", Integer.toString(limit)); 133 | if (c.moveToFirst()) { 134 | do { 135 | Ad item = new Ad(); 136 | item = GetAdItem(item, c); 137 | itemList.add(item); 138 | } while (c.moveToNext()); 139 | } 140 | c.close(); 141 | return itemList; 142 | } 143 | 144 | public long GetMaxAdID() { 145 | long max = 0; 146 | SQLiteDatabase db = this.getReadableDatabase(); 147 | Cursor c = db.query(TABLE_ADS, new String[]{"MAX(" + KEY_ORIGINALID + ")"}, null, null, null, null, null); 148 | if (c.moveToFirst()) { 149 | max = c.getLong(0); 150 | } 151 | c.close(); 152 | return max; 153 | } 154 | 155 | public int GetAdsLatestUpdate(Long itemid, Integer limit) { 156 | int latestUpdate = 0; 157 | String selectQuery = "SELECT MAX(" + KEY_UPDATEAT + ") FROM ( SELECT " + KEY_UPDATEAT + " FROM " + TABLE_ADS 158 | + " WHERE " + KEY_ORIGINALID + " < " + itemid + " ORDER BY " + KEY_ORIGINALID + " DESC LIMIT " + limit + " )"; 159 | SQLiteDatabase db = this.getReadableDatabase(); 160 | 161 | Cursor c = db.rawQuery(selectQuery, null); 162 | if (c.moveToFirst()) { 163 | latestUpdate = c.getInt(0); 164 | } 165 | c.close(); 166 | return latestUpdate; 167 | } 168 | 169 | public void AddAdsBatch(JSONArray jsonArray) { 170 | Date currentDate = new Date(); 171 | Long currentTime = currentDate.getTime() / 1000; 172 | SQLiteDatabase db = this.getWritableDatabase(); 173 | db.beginTransaction(); 174 | for (int i = 0; i < jsonArray.length(); i++) { 175 | try { 176 | JSONObject jsonObject = (JSONObject) jsonArray.get(i); 177 | ContentValues values = new ContentValues(); 178 | values.put(KEY_ORIGINALID, jsonObject.getLong("id")); 179 | values.put(KEY_FROMID, jsonObject.getLong("fromUserId")); 180 | values.put(KEY_ADTYPE, jsonObject.getInt("adType")); 181 | values.put(KEY_STATUS, jsonObject.getInt("status")); 182 | values.put(KEY_SEGMENT, jsonObject.getString("segment")); 183 | values.put(KEY_LOCATION, jsonObject.getString("location")); 184 | values.put(KEY_DEVICEVERSION, jsonObject.getInt("deviceVersion")); 185 | values.put(KEY_WEIGHT, jsonObject.getString("weight")); 186 | values.put(KEY_PRICE, jsonObject.getString("price")); 187 | values.put(KEY_TITLE, jsonObject.getString("title")); 188 | values.put(KEY_SUBTITLE, jsonObject.getString("subtitle")); 189 | values.put(KEY_DESCRIPTION, jsonObject.getString("description")); 190 | values.put(KEY_DESCRIPTIONSHORT, jsonObject.getString("descriptionShort")); 191 | values.put(KEY_CATEGORY, jsonObject.getString("category")); 192 | values.put(KEY_RATING, jsonObject.getInt("rating")); 193 | values.put(KEY_INSTALLS, jsonObject.getInt("installs")); 194 | values.put(KEY_VERSION, jsonObject.getString("version")); 195 | values.put(KEY_DEVELOPER, jsonObject.getString("developer")); 196 | values.put(KEY_EMAIL, jsonObject.getString("email")); 197 | values.put(KEY_ADDRESS, jsonObject.getString("address")); 198 | values.put(KEY_WEBSITE, jsonObject.getString("website")); 199 | values.put(KEY_LINKURL, jsonObject.getString("linkUrl")); 200 | values.put(KEY_PACKAGENAME, jsonObject.getString("packageName")); 201 | values.put(KEY_PREVIEWIMAGEURL, jsonObject.getString("previewImgUrl")); 202 | values.put(KEY_IMAGEURL, jsonObject.getString("imgUrl")); 203 | values.put(KEY_PREVIEWVIDEOIMAGEURL, jsonObject.getString("previewVideoImgUrl")); 204 | values.put(KEY_VIDEOURL, jsonObject.getString("videoUrl")); 205 | values.put(KEY_TEXT1, jsonObject.getString("text1")); 206 | values.put(KEY_TEXT2, jsonObject.getString("text2")); 207 | values.put(KEY_TEXT3, jsonObject.getString("text3")); 208 | values.put(KEY_NUMBER1, jsonObject.getInt("number1")); 209 | values.put(KEY_NUMBER2, jsonObject.getInt("number2")); 210 | values.put(KEY_NUMBER3, jsonObject.getInt("number3")); 211 | //Check dates are smaller than current time. Sometimes, dates are incorrect on server. Prevent permanent errors. 212 | if (jsonObject.getInt("createAt") > currentTime) { 213 | values.put(KEY_CREATEAT, currentTime); 214 | } else { 215 | values.put(KEY_CREATEAT, jsonObject.getInt("createAt")); 216 | } 217 | if (jsonObject.getInt("updateAt") > currentTime) { 218 | values.put(KEY_UPDATEAT, currentTime); 219 | } else { 220 | values.put(KEY_UPDATEAT, jsonObject.getInt("updateAt")); 221 | } 222 | values.put(KEY_STARTAT, jsonObject.getInt("startAt")); 223 | values.put(KEY_ENDAT, jsonObject.getInt("endAt")); 224 | values.put(KEY_REMOVEAT, jsonObject.getInt("removeAt")); 225 | 226 | //Attempt to update posts. If update fails, post is new and insert instead. 227 | long id = db.update(TABLE_ADS, values, KEY_ORIGINALID + "=?", new String[]{String.valueOf(jsonObject.getLong("id"))}); 228 | if (id == 0) { 229 | id = db.insert(TABLE_ADS, null, values); 230 | } 231 | 232 | } catch (Throwable t) { 233 | 234 | Log.e(mActivity, "Error JSON: " + t.toString()); 235 | 236 | } 237 | } 238 | db.setTransactionSuccessful(); 239 | db.endTransaction(); 240 | db.close(); 241 | } 242 | 243 | public Ad GetAdItem(Ad item, Cursor c) { 244 | 245 | item.setId(c.getLong(c.getColumnIndexOrThrow(KEY_ORIGINALID))); 246 | item.setFromUserId(c.getLong(c.getColumnIndexOrThrow(KEY_FROMID))); 247 | item.setAdType(c.getInt(c.getColumnIndexOrThrow(KEY_ADTYPE))); 248 | item.setStatus(c.getInt(c.getColumnIndexOrThrow(KEY_STATUS))); 249 | item.setSegment(c.getString(c.getColumnIndexOrThrow(KEY_SEGMENT))); 250 | item.setLocation(c.getString(c.getColumnIndexOrThrow(KEY_LOCATION))); 251 | item.setDeviceVersion(c.getInt(c.getColumnIndexOrThrow(KEY_DEVICEVERSION))); 252 | item.setWeight(c.getInt(c.getColumnIndexOrThrow(KEY_WEIGHT))); 253 | item.setPrice(c.getInt(c.getColumnIndexOrThrow(KEY_PRICE))); 254 | item.setTitle(c.getString(c.getColumnIndexOrThrow(KEY_TITLE))); 255 | item.setSubTitle(c.getString(c.getColumnIndexOrThrow(KEY_SUBTITLE))); 256 | item.setDescription(c.getString(c.getColumnIndexOrThrow(KEY_DESCRIPTION))); 257 | item.setDescriptionShort(c.getString(c.getColumnIndexOrThrow(KEY_DESCRIPTIONSHORT))); 258 | item.setCategory(c.getString(c.getColumnIndexOrThrow(KEY_CATEGORY))); 259 | item.setRating(c.getInt(c.getColumnIndexOrThrow(KEY_RATING))); 260 | item.setInstalls(c.getInt(c.getColumnIndexOrThrow(KEY_INSTALLS))); 261 | item.setVersion(c.getString(c.getColumnIndexOrThrow(KEY_VERSION))); 262 | item.setDeveloper(c.getString(c.getColumnIndexOrThrow(KEY_DEVELOPER))); 263 | item.setEmail(c.getString(c.getColumnIndexOrThrow(KEY_EMAIL))); 264 | item.setAddress(c.getString(c.getColumnIndexOrThrow(KEY_ADDRESS))); 265 | item.setWebsite(c.getString(c.getColumnIndexOrThrow(KEY_WEBSITE))); 266 | item.setLinkUrl(c.getString(c.getColumnIndexOrThrow(KEY_LINKURL))); 267 | item.setMyPackageName(c.getString(c.getColumnIndexOrThrow(KEY_PACKAGENAME))); 268 | item.setPreviewImageUrl(c.getString(c.getColumnIndexOrThrow(KEY_PREVIEWIMAGEURL))); 269 | item.setImageUrl(c.getString(c.getColumnIndexOrThrow(KEY_IMAGEURL))); 270 | item.setPreviewVideoImageUrl(c.getString(c.getColumnIndexOrThrow(KEY_PREVIEWVIDEOIMAGEURL))); 271 | item.setVideoUrl(c.getString(c.getColumnIndexOrThrow(KEY_VIDEOURL))); 272 | item.setText1(c.getString(c.getColumnIndexOrThrow(KEY_TEXT1))); 273 | item.setText2(c.getString(c.getColumnIndexOrThrow(KEY_TEXT2))); 274 | item.setText3(c.getString(c.getColumnIndexOrThrow(KEY_TEXT3))); 275 | item.setNumber1(c.getInt(c.getColumnIndexOrThrow(KEY_NUMBER1))); 276 | item.setNumber2(c.getInt(c.getColumnIndexOrThrow(KEY_NUMBER2))); 277 | item.setNumber3(c.getInt(c.getColumnIndexOrThrow(KEY_NUMBER3))); 278 | item.setCreateAt(c.getInt(c.getColumnIndexOrThrow(KEY_CREATEAT))); 279 | item.setUpdateAt(c.getInt(c.getColumnIndexOrThrow(KEY_UPDATEAT))); 280 | item.setStartAt(c.getInt(c.getColumnIndexOrThrow(KEY_STARTAT))); 281 | item.setEndAt(c.getInt(c.getColumnIndexOrThrow(KEY_ENDAT))); 282 | item.setRemoveAt(c.getInt(c.getColumnIndexOrThrow(KEY_REMOVEAT))); 283 | 284 | return item; 285 | } 286 | } 287 | 288 | -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/LruBitmapCache.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import androidx.collection.LruCache; 6 | 7 | import com.android.volley.toolbox.ImageLoader.ImageCache; 8 | 9 | public class LruBitmapCache extends LruCache implements 10 | ImageCache { 11 | public LruBitmapCache() { 12 | this(getDefaultLruCacheSize()); 13 | } 14 | 15 | public LruBitmapCache(int sizeInKiloBytes) { 16 | super(sizeInKiloBytes); 17 | } 18 | 19 | public static int getDefaultLruCacheSize() { 20 | final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); 21 | final int cacheSize = maxMemory / 8; 22 | 23 | return cacheSize; 24 | } 25 | 26 | @Override 27 | protected int sizeOf(String key, Bitmap value) { 28 | return value.getRowBytes() * value.getHeight() / 1024; 29 | } 30 | 31 | @Override 32 | public Bitmap getBitmap(String url) { 33 | return get(url); 34 | } 35 | 36 | @Override 37 | public void putBitmap(String url, Bitmap bitmap) { 38 | put(url, bitmap); 39 | } 40 | } -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/Utils.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.content.ActivityNotFoundException; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.net.Uri; 8 | import android.widget.Toast; 9 | 10 | public class Utils { 11 | 12 | public static Boolean isAppInstalled(Context context, String appName) { 13 | PackageManager pm = context.getPackageManager(); 14 | boolean installed; 15 | try { 16 | pm.getPackageInfo(appName, PackageManager.GET_ACTIVITIES); 17 | installed = true; 18 | } catch (PackageManager.NameNotFoundException e) { 19 | installed = false; 20 | } 21 | return installed; 22 | } 23 | 24 | public static void OpenDeveloperUrl(Context context, String url) { 25 | Intent intent = new Intent(Intent.ACTION_VIEW); 26 | intent.setData(Uri.parse("https://play.google.com/store/apps/dev?id=" + url)); 27 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 28 | try { 29 | context.startActivity(intent); 30 | } catch (ActivityNotFoundException e) { 31 | Toast.makeText(context, "Could not open Google Play", Toast.LENGTH_SHORT).show(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /crosspromotion/src/main/java/stream/crosspromotion/VolleySingleton.java: -------------------------------------------------------------------------------- 1 | package stream.crosspromotion; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.text.TextUtils; 6 | 7 | import androidx.collection.LruCache; 8 | 9 | import com.android.volley.Request; 10 | import com.android.volley.RequestQueue; 11 | import com.android.volley.toolbox.ImageLoader; 12 | import com.android.volley.toolbox.Volley; 13 | 14 | public class VolleySingleton { 15 | 16 | private static VolleySingleton mInstance; 17 | private final String TAG = getClass().getSimpleName(); 18 | private RequestQueue mRequestQueue; 19 | private ImageLoader mImageLoader; 20 | private Context mContext; 21 | 22 | private VolleySingleton(Context context) { 23 | mContext = context; 24 | mRequestQueue = getRequestQueue(); 25 | 26 | mImageLoader = new ImageLoader(mRequestQueue, 27 | new ImageLoader.ImageCache() { 28 | private final LruCache 29 | cache = new LruCache<>(20); 30 | 31 | @Override 32 | public Bitmap getBitmap(String url) { 33 | return cache.get(url); 34 | } 35 | 36 | @Override 37 | public void putBitmap(String url, Bitmap bitmap) { 38 | cache.put(url, bitmap); 39 | } 40 | }); 41 | } 42 | 43 | public static synchronized VolleySingleton getInstance(Context context) { 44 | if (mInstance == null) { 45 | mInstance = new VolleySingleton(context); 46 | } 47 | return mInstance; 48 | } 49 | 50 | public RequestQueue getRequestQueue() { 51 | 52 | if (mRequestQueue == null) { 53 | mRequestQueue = Volley.newRequestQueue(mContext); 54 | } 55 | 56 | return mRequestQueue; 57 | } 58 | 59 | public ImageLoader getImageLoader() { 60 | getRequestQueue(); 61 | if (mImageLoader == null) { 62 | mImageLoader = new ImageLoader(this.mRequestQueue, 63 | new LruBitmapCache()); 64 | } 65 | return this.mImageLoader; 66 | } 67 | 68 | public void addToRequestQueue(Request req, String tag) { 69 | // set the default tag if tag is empty 70 | req.setTag(TextUtils.isEmpty(tag) ? TAG : tag); 71 | getRequestQueue().add(req); 72 | } 73 | 74 | public void addToRequestQueue(Request req) { 75 | req.setTag(TAG); 76 | getRequestQueue().add(req); 77 | } 78 | 79 | public void cancelPendingRequests(Object tag) { 80 | if (mRequestQueue != null) { 81 | mRequestQueue.cancelAll(tag); 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/ic_menu_camera.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/ic_menu_gallery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/ic_menu_manage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/ic_menu_send.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/ic_menu_share.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/ic_menu_slideshow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/icon_apk_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 19 | 23 | 27 | 31 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/icon_plus_fit_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 20 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/icon_star_tiny.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v21/icon_verified_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 16 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-xhdpi/icon_apk_circle_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/crosspromotion/src/main/res/drawable-xhdpi/icon_apk_circle_old.png -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-xhdpi/icon_plus_fit_white_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/crosspromotion/src/main/res/drawable-xhdpi/icon_plus_fit_white_old.png -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-xhdpi/icon_star_tiny_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/crosspromotion/src/main/res/drawable-xhdpi/icon_star_tiny_old.png -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable-xhdpi/icon_verified_circle_old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/crosspromotion/src/main/res/drawable-xhdpi/icon_verified_circle_old.png -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/bg_rrect_install.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/bg_rrect_install_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/bg_rrect_install_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/bg_rrect_rating.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/bg_rrect_rating_selected.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/bg_rrect_rating_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/ic_android_apk_icon_circle.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/icon_googleplay.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 15 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/layout-v21/item_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 19 | 20 | 26 | 27 | 49 | 50 | 51 | 60 | 61 | 72 | 73 | 83 | 84 | 85 | 90 | 91 | 100 | 101 | 117 | 118 | 119 | 120 | 125 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/layout/activity_acp.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 20 | 21 | 22 | 27 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/layout/fragment_acp.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 23 | 24 | 25 | 32 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/layout/item_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 19 | 20 | 26 | 27 | 48 | 49 | 50 | 59 | 60 | 71 | 72 | 82 | 83 | 84 | 89 | 90 | 99 | 100 | 115 | 116 | 117 | 118 | 123 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 2 |

4 | 11 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #0f9d58 4 | #0c7e46 5 | #55cf86 6 | 7 | 8 | #2D2D2D 9 | #8C8C8C 10 | #757575 11 | 12 | 13 | #fdfdfd 14 | #efefef 15 | 16 | 17 | #0f9d58 18 | 19 | 20 | #FFFFFF 21 | 22 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 8dp 6 | 176dp 7 | 8 | 9 | 2dp 10 | 4dp 11 | 6dp 12 | 8dp 13 | 12dp 14 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Cross Promotion 3 | 8647251961827166428 4 | https://crosspromotion.codelesscdn.com/ 5 | 6 | More Great Apps 7 | More Apps 8 | 9 | -------------------------------------------------------------------------------- /crosspromotion/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /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 | android.enableJetifier=true 13 | android.useAndroidX=true 14 | org.gradle.jvmargs=-Xmx1536m 15 | 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rayliverified/AndroidCrossPromotion/78c2db973516dd82314962eb47eb6c0f7996c782/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat May 04 20:14:57 CDT 2019 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-5.4-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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /server/addad.php: -------------------------------------------------------------------------------- 1 | Add Ad - START"; 5 | 6 | $currentTime = time(); 7 | $ads = new ads($dbo); 8 | 9 | $ad = array("fromUserId" => 1, 10 | "adType" => 0, 11 | "status" => 0, 12 | "segment" => "Default", 13 | "location" => "Global", 14 | "deviceVersion" => 21, 15 | "weight" => 51, 16 | "price" => 0, 17 | "title" => "Message AI - Write Better Messages (Free)", 18 | "subtitle" => "Send better, more positive messages and improve relationships 💝", 19 | "description" => "Have you ever sent a text you later regretted? Maybe you were too negative or angry at the time. Message AI warns you when you're about to send a message that could harm your relationships! 20 | 21 | In addition, Message AI helps you understand how people really feel by analyzing conversations in Messenger, WhatsApp, Tinder, Snapchat, Kik, Instagram, and Line. All messaging apps are supported! 22 | 23 | How it works: 24 | Our MessageIQ artificial intelligence analyzes your messages and shows you your Positivity Score. We score each word from -100 to 100 so you can identify positive/negative emotions. 25 | 26 | Better communication is the #1 way to improve relationships. Many people don't realize how angry they sound when tired and end up hurting the people they care about unintentionally! 27 | 28 | We're in this together 29 | Message AI is the friend that always looks out for you. We'll not only warn you if you sound negative, we'll also show you when your friends are being negative. 30 | 31 | Features: 32 | Find out if your crush likes you back ❤️ 33 | Who secretly likes you? Discover your secret admirers 😙 34 | Monitor your relationship with artificial intelligence! 35 | Be more positive and increase your likability 🔥 36 | Identify passive aggressiveness so you can defuse toxic situations. 37 | Uncover hidden attitudes people have. How do people REALLY feel? 38 | Pick up on warning signals that someone's about to ghost you with AI 👻 39 | Build better relationships with improve communication. 40 | Be a better friend and more positive person!", 41 | "descriptionShort" => "Message AI helps you sound more positive in your messages, increasing your likability and improving relationships 💝", 42 | "category" => "Social", 43 | "rating" => 5.0, 44 | "installs" => 500, 45 | "version" => "0.9.4", 46 | "developer" => "Straight Up", 47 | "email" => "support@messageai.co", 48 | "address" => "Kansas City, Kansas", 49 | "website" => "http://messageai.co", 50 | "linkUrl" => "https://play.google.com/store/apps/details?id=ai.message.lite", 51 | "packageName" => "ai.message.lite", 52 | "previewImgUrl" => "https://lh3.googleusercontent.com/5wtW75qqbqk1-iprBeW4hAxy6iw56zX6EQ8mRBfoUlWWZtxYDpvtZw8EnjpdjJ7VnAUg=s128-rw", 53 | "imgUrl" => "https://lh3.googleusercontent.com/5wtW75qqbqk1-iprBeW4hAxy6iw56zX6EQ8mRBfoUlWWZtxYDpvtZw8EnjpdjJ7VnAUg=s256-rw", 54 | "previewVideoImgUrl" => "https://lh3.googleusercontent.com/gTxlSPIPzfe1NoBsryU5dkw5I9kuJRE6RsznCWav76MaoKHfm0YwbD7oF4AbuAxe6QE=w360", 55 | "videoUrl" => "", 56 | "text1" => "", 57 | "text2" => "", 58 | "text3" => "", 59 | "number1" => 0, 60 | "number2" => 0, 61 | "number3" => 0, 62 | "startAt" => $currentTime, 63 | "endAt" => 2000000000); 64 | 65 | $exists = $ads->existsApp($ad["packageName"]); 66 | if ($exists["error"]) 67 | { 68 | $ads->add($ad); 69 | echo "\rAd Added"; 70 | } 71 | else 72 | { 73 | echo "\rAd Exists - Not Added"; 74 | } 75 | 76 | unset($ad); 77 | echo "\rAdd Ad - END"; 78 | 79 | } catch (Exception $e) { 80 | 81 | die ($e->getMessage()); 82 | } 83 | -------------------------------------------------------------------------------- /server/ads.get.php: -------------------------------------------------------------------------------- 1 | true, 17 | "error_code" => ERROR_UNKNOWN); 18 | 19 | $ads = new ads($dbo); 20 | $result = $ads->get($updateAt); 21 | 22 | echo json_encode($result); 23 | exit; 24 | } 25 | -------------------------------------------------------------------------------- /server/class.ads.php: -------------------------------------------------------------------------------- 1 | setRequestFrom($requestFrom); 12 | } 13 | 14 | public function getAllCount() 15 | { 16 | $stmt = $this->db->prepare("SELECT count(*) FROM ads"); 17 | $stmt->execute(); 18 | 19 | return $number_of_rows = $stmt->fetchColumn(); 20 | } 21 | 22 | public function getMaxIdAds() 23 | { 24 | $stmt = $this->db->prepare("SELECT MAX(id) FROM ads"); 25 | $stmt->execute(); 26 | 27 | return $number_of_rows = $stmt->fetchColumn(); 28 | } 29 | 30 | public function exists($adsId) 31 | { 32 | $result = array("error" => true, 33 | "error_code" => ERROR_UNKNOWN); 34 | 35 | $stmt = $this->db->prepare("SELECT * FROM ads WHERE id = (:adsId) LIMIT 1"); 36 | $stmt->bindParam(":adsId", $adsId, PDO::PARAM_INT); 37 | 38 | if ($stmt->execute()) { 39 | 40 | if ($stmt->rowCount() > 0) { 41 | 42 | $result = array("error" => false, 43 | "error_code" => ERROR_SUCCESS); 44 | } 45 | } 46 | 47 | return $result; 48 | } 49 | 50 | public function existsApp($app) 51 | { 52 | $result = array("error" => true, 53 | "error_code" => ERROR_UNKNOWN); 54 | 55 | $stmt = $this->db->prepare("SELECT * FROM ads WHERE packageName = (:packageName) LIMIT 1"); 56 | $stmt->bindParam(":packageName", $app, PDO::PARAM_INT); 57 | 58 | if ($stmt->execute()) { 59 | 60 | if ($stmt->rowCount() > 0) { 61 | 62 | $result = array("error" => false, 63 | "error_code" => ERROR_SUCCESS); 64 | } 65 | } 66 | 67 | return $result; 68 | } 69 | 70 | public function info($adsId) 71 | { 72 | $result = array("error" => true, 73 | "error_code" => ERROR_UNKNOWN); 74 | 75 | $stmt = $this->db->prepare("SELECT * FROM ads WHERE id = (:adsId) LIMIT 1"); 76 | $stmt->bindParam(":adsId", $adsId, PDO::PARAM_INT); 77 | 78 | if ($stmt->execute()) { 79 | 80 | if ($stmt->rowCount() > 0) { 81 | 82 | $row = $stmt->fetch(); 83 | 84 | $result = array("error" => false, 85 | "id" => $row['id'], 86 | "fromUserId" => $row['fromUserId'], 87 | "adType" => $row['adType'], 88 | "status" => $row['status'], 89 | "segment" => $row['segment'], 90 | "location" => $row['location'], 91 | "deviceVersion" => $row['deviceVersion'], 92 | "weight" => $row['weight'], 93 | "price" => $row['price'], 94 | "title" => $row['title'], 95 | "subtitle" => $row['subtitle'], 96 | "description" => $row['description'], 97 | "descriptionShort" => $row['descriptionShort'], 98 | "category" => $row['category'], 99 | "rating" => $row['rating'], 100 | "installs" => $row['installs'], 101 | "version" => $row['version'], 102 | "developer" => $row['developer'], 103 | "email" => $row['email'], 104 | "address" => $row['address'], 105 | "website" => $row['website'], 106 | "linkUrl" => $row['linkUrl'], 107 | "packageName" => $row['packageName'], 108 | "previewImgUrl" => $row['previewImgUrl'], 109 | "imgUrl" => $row['imgUrl'], 110 | "previewVideoImgUrl" => $row['previewVideoImgUrl'], 111 | "videoUrl" => $row['videoUrl'], 112 | "text1" => $row['text1'], 113 | "text2" => $row['text2'], 114 | "text3" => $row['text3'], 115 | "number1" => $row['number1'], 116 | "number2" => $row['number2'], 117 | "number3" => $row['number3'], 118 | "createAt" => $row['createAt'], 119 | "updateAt" => $row['updateAt'], 120 | "startAt" => $row['startAt'], 121 | "endAt" => $row['endAt'], 122 | "removeAt" => $row['removeAt'], 123 | "views" => $row['views'], 124 | "clicks" => $row['clicks'], 125 | "sales" => $row['sales']); 126 | } 127 | } 128 | 129 | return $result; 130 | } 131 | 132 | public function add($ad) 133 | { 134 | $result = array("error" => false, 135 | "error_code" => ERROR_SUCCESS, 136 | "items" => array()); 137 | 138 | $currentTime = time(); 139 | $stmt = $this->db->prepare("INSERT INTO ads (fromUserId, adType, status, segment, location, deviceVersion, 140 | weight, price, title, subtitle, description, descriptionShort, category, rating, installs, version, developer, email, address, 141 | website, linkUrl, packageName, previewImgUrl, imgUrl, previewVideoImgUrl, videoUrl, text1, text2, text3, number1, number2, 142 | number3, createAt, updateAt, startAt, endAt) value (:fromUserId, :adType, :status, :segment, :location, :deviceVersion, 143 | :weight, :price, :title, :subtitle, :description, :descriptionShort, :category, :rating, :installs, :version, :developer, 144 | :email, :address, :website, :linkUrl, :packageName, :previewImgUrl, :imgUrl, :previewVideoImgUrl, :videoUrl, :text1, :text2, 145 | :text3, :number1, :number2, :number3, :createAt, :updateAt, :startAt, :endAt)"); 146 | $stmt->bindParam('fromUserId', $ad['fromUserId'], PDO::PARAM_INT); 147 | $stmt->bindParam('adType', $ad['adType'], PDO::PARAM_INT); 148 | $stmt->bindParam('status', $ad['status'], PDO::PARAM_INT); 149 | $stmt->bindParam('segment', $ad['segment'], PDO::PARAM_STR); 150 | $stmt->bindParam('location', $ad['location'], PDO::PARAM_STR); 151 | $stmt->bindParam('deviceVersion', $ad['deviceVersion'], PDO::PARAM_INT); 152 | $stmt->bindParam('weight', $ad['weight'], PDO::PARAM_INT); 153 | $stmt->bindParam('price', $ad['price'], PDO::PARAM_INT); 154 | $stmt->bindParam('title', $ad['title'], PDO::PARAM_STR); 155 | $stmt->bindParam('subtitle', $ad['subtitle'], PDO::PARAM_STR); 156 | $stmt->bindParam('description', $ad['description'], PDO::PARAM_STR); 157 | $stmt->bindParam('descriptionShort', $ad['descriptionShort'], PDO::PARAM_STR); 158 | $stmt->bindParam('category', $ad['category'], PDO::PARAM_STR); 159 | $stmt->bindParam('rating', $ad['rating'], PDO::PARAM_STR); 160 | $stmt->bindParam('installs', $ad['installs'], PDO::PARAM_INT); 161 | $stmt->bindParam('version', $ad['version'], PDO::PARAM_STR); 162 | $stmt->bindParam('developer', $ad['developer'], PDO::PARAM_STR); 163 | $stmt->bindParam('email', $ad['email'], PDO::PARAM_STR); 164 | $stmt->bindParam('address', $ad['address'], PDO::PARAM_STR); 165 | $stmt->bindParam('website', $ad['website'], PDO::PARAM_STR); 166 | $stmt->bindParam('linkUrl', $ad['linkUrl'], PDO::PARAM_STR); 167 | $stmt->bindParam('packageName', $ad['packageName'], PDO::PARAM_STR); 168 | $stmt->bindParam('previewImgUrl', $ad['previewImgUrl'], PDO::PARAM_STR); 169 | $stmt->bindParam('imgUrl', $ad['imgUrl'], PDO::PARAM_STR); 170 | $stmt->bindParam('previewVideoImgUrl', $ad['previewVideoImgUrl'], PDO::PARAM_STR); 171 | $stmt->bindParam('videoUrl', $ad['videoUrl'], PDO::PARAM_STR); 172 | $stmt->bindParam('text1', $ad['text1'], PDO::PARAM_STR); 173 | $stmt->bindParam('text2', $ad['text2'], PDO::PARAM_STR); 174 | $stmt->bindParam('text3', $ad['text3'], PDO::PARAM_STR); 175 | $stmt->bindParam('number1', $ad['number1'], PDO::PARAM_INT); 176 | $stmt->bindParam('number2', $ad['number2'], PDO::PARAM_INT); 177 | $stmt->bindParam('number3', $ad['number3'], PDO::PARAM_INT); 178 | $stmt->bindParam('createAt', $currentTime, PDO::PARAM_INT); 179 | $stmt->bindParam('updateAt', $currentTime, PDO::PARAM_INT); 180 | $stmt->bindParam('startAt', $ad['startAt'], PDO::PARAM_INT); 181 | $stmt->bindParam('endAt', $ad['endAt'], PDO::PARAM_INT); 182 | 183 | if ($stmt->execute()) { 184 | 185 | $result = array("error" => false, 186 | "error_code" => ERROR_SUCCESS, 187 | "itemId" => $this->db->lastInsertId(), 188 | "item" => $this->info($this->db->lastInsertId())); 189 | } 190 | 191 | return $result; 192 | } 193 | 194 | public function get($updateAt = 0) 195 | { 196 | $result = array("error" => false, 197 | "error_code" => ERROR_SUCCESS, 198 | "items" => array()); 199 | 200 | $currentTime = time(); 201 | $stmt = $this->db->prepare("SELECT * FROM ads WHERE removeAt = 0 AND updateAt > (:updateAt) AND endAt > (:currentTime) ORDER BY id DESC"); 202 | $stmt->bindParam(':updateAt', $updateAt, PDO::PARAM_INT); 203 | $stmt->bindParam(':currentTime', $currentTime, PDO::PARAM_INT); 204 | 205 | if ($stmt->execute()) { 206 | 207 | if ($stmt->rowCount() > 0) { 208 | 209 | while ($row = $stmt->fetch()) { 210 | 211 | $ad = array("id" => $row['id'], 212 | "fromUserId" => $row['fromUserId'], 213 | "adType" => $row['adType'], 214 | "status" => $row['status'], 215 | "segment" => $row['segment'], 216 | "location" => $row['location'], 217 | "deviceVersion" => $row['deviceVersion'], 218 | "weight" => $row['weight'], 219 | "price" => $row['price'], 220 | "title" => $row['title'], 221 | "subtitle" => $row['subtitle'], 222 | "description" => $row['description'], 223 | "descriptionShort" => $row['descriptionShort'], 224 | "category" => $row['category'], 225 | "rating" => $row['rating'], 226 | "installs" => $row['installs'], 227 | "version" => $row['version'], 228 | "developer" => $row['developer'], 229 | "email" => $row['email'], 230 | "address" => $row['address'], 231 | "website" => $row['website'], 232 | "linkUrl" => $row['linkUrl'], 233 | "packageName" => $row['packageName'], 234 | "previewImgUrl" => $row['previewImgUrl'], 235 | "imgUrl" => $row['imgUrl'], 236 | "previewVideoImgUrl" => $row['previewVideoImgUrl'], 237 | "videoUrl" => $row['videoUrl'], 238 | "text1" => $row['text1'], 239 | "text2" => $row['text2'], 240 | "text3" => $row['text3'], 241 | "number1" => $row['number1'], 242 | "number2" => $row['number2'], 243 | "number3" => $row['number3'], 244 | "createAt" => $row['createAt'], 245 | "updateAt" => $row['updateAt'], 246 | "startAt" => $row['startAt'], 247 | "endAt" => $row['endAt'], 248 | "removeAt" => $row['removeAt']); 249 | 250 | array_push($result['items'], $ad); 251 | unset($ad); 252 | } 253 | } 254 | } 255 | 256 | return $result; 257 | } 258 | 259 | public function removeByUser($fromUserId) 260 | { 261 | 262 | $result = array("error" => true, 263 | "error_code" => ERROR_UNKNOWN, 264 | "count" => 0); 265 | 266 | $stmt = $this->db->prepare("SELECT id FROM ads WHERE fromUserId = (:fromUserId) AND removeAt = 0"); 267 | $stmt->bindParam(':fromUserId', $fromUserId, PDO::PARAM_STR); 268 | 269 | if ($stmt->execute()) { 270 | 271 | while ($row = $stmt->fetch()) { 272 | 273 | $this->remove($row['id']); 274 | } 275 | 276 | $result = array("error" => false, 277 | "error_code" => ERROR_SUCCESS, 278 | "count" => $stmt->rowCount()); 279 | } 280 | 281 | return $result; 282 | } 283 | 284 | public function remove($adsId) 285 | { 286 | $result = array("error" => true); 287 | 288 | $itemInfo = $this->exists($adsId); 289 | 290 | if ($itemInfo['error'] === true) { 291 | 292 | return $result; 293 | } 294 | 295 | $currentTime = time(); 296 | 297 | $stmt = $this->db->prepare("UPDATE ads SET removeAt = (:removeAt) WHERE id = (:adsId)"); 298 | $stmt->bindParam(":adsId", $adsId, PDO::PARAM_INT); 299 | $stmt->bindParam(":removeAt", $currentTime, PDO::PARAM_INT); 300 | 301 | if ($stmt->execute()) { 302 | 303 | $result = array("error" => false); 304 | } 305 | 306 | return $result; 307 | } 308 | 309 | public function setLanguage($language) 310 | { 311 | $this->language = $language; 312 | } 313 | 314 | public function getLanguage() 315 | { 316 | return $this->language; 317 | } 318 | 319 | public function setRequestFrom($requestFrom) 320 | { 321 | $this->requestFrom = $requestFrom; 322 | } 323 | 324 | public function getRequestFrom() 325 | { 326 | return $this->requestFrom; 327 | } 328 | } 329 | -------------------------------------------------------------------------------- /server/class.api.php: -------------------------------------------------------------------------------- 1 | true, 12 | "error_code" => $error_code, 13 | "error_description" => $error_description); 14 | 15 | echo json_encode($result); 16 | exit; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /server/class.db_connect.php: -------------------------------------------------------------------------------- 1 | db = $db; 11 | 12 | } else { 13 | 14 | $dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME; 15 | 16 | try { 17 | 18 | $this->db = new PDO($dsn, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4")); 19 | 20 | } catch (Exception $e) { 21 | 22 | die ($e->getMessage()); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /server/class.helper.php: -------------------------------------------------------------------------------- 1 | real_escape_string($text); 37 | 38 | return $text; 39 | } 40 | 41 | function clean($string) { 42 | 43 | $string = str_replace(' ', '', $string); // Replaces all spaces with hyphens. 44 | 45 | return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. 46 | } 47 | 48 | static function clearInt($value) 49 | { 50 | $value = intval($value); 51 | if ($value < 0) { 52 | 53 | $value = 0; 54 | } 55 | 56 | return $value; 57 | } 58 | 59 | static function ip_addr() 60 | { 61 | (string) $ip_addr = 'undefined'; 62 | 63 | if (isset($_SERVER['REMOTE_ADDR'])) $ip_addr = $_SERVER['REMOTE_ADDR']; 64 | 65 | return $ip_addr; 66 | } 67 | 68 | static function u_agent() 69 | { 70 | (string) $u_agent = 'undefined'; 71 | 72 | if (isset($_SERVER['HTTP_USER_AGENT'])) $u_agent = $_SERVER['HTTP_USER_AGENT']; 73 | 74 | return $u_agent; 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /server/db.php: -------------------------------------------------------------------------------- 1 | $val) { 5 | 6 | define($name, $val); 7 | } 8 | 9 | foreach ($B as $name => $val) { 10 | 11 | define($name, $val); 12 | } 13 | 14 | $dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME; 15 | $dbo = new PDO($dsn, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4")); 16 | 17 | function __autoload($class) 18 | { 19 | $filename = "class.".$class.".php"; 20 | 21 | if (file_exists($filename)) { 22 | 23 | include_once($filename); 24 | } 25 | } -------------------------------------------------------------------------------- /server/initialize.php: -------------------------------------------------------------------------------- 1 | prepare("CREATE TABLE IF NOT EXISTS ads ( 33 | id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 34 | fromUserId int(11) UNSIGNED DEFAULT 0, 35 | adType int(11) UNSIGNED DEFAULT 0, 36 | status int(11) UNSIGNED DEFAULT 0, 37 | segment VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 38 | location VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 39 | deviceVersion int(11) UNSIGNED DEFAULT 0, 40 | weight int(11) UNSIGNED DEFAULT 0, 41 | price int(11) UNSIGNED DEFAULT 0, 42 | title varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 43 | subtitle varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 44 | description varchar(4000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 45 | descriptionShort varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 46 | category VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 47 | rating DECIMAL(4, 3) NOT NULL DEFAULT 5.0, 48 | installs int(11) UNSIGNED DEFAULT 0, 49 | version VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 50 | developer VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 51 | email VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 52 | address VARCHAR(80) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 53 | website VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 54 | linkUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 55 | packageName VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 56 | previewImgUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 57 | imgUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 58 | previewVideoImgUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 59 | videoUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 60 | text1 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 61 | text2 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 62 | text3 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 63 | number1 int(11) UNSIGNED DEFAULT 0, 64 | number2 int(11) UNSIGNED DEFAULT 0, 65 | number3 int(11) UNSIGNED DEFAULT 0, 66 | createAt int(11) UNSIGNED DEFAULT 0, 67 | updateAt int(11) UNSIGNED DEFAULT 0, 68 | startAt int(11) UNSIGNED DEFAULT 0, 69 | endAt int(11) UNSIGNED DEFAULT 0, 70 | removeAt int(11) UNSIGNED DEFAULT 0, 71 | views int(11) UNSIGNED DEFAULT 0, 72 | clicks int(11) UNSIGNED DEFAULT 0, 73 | sales int(11) UNSIGNED DEFAULT 0, 74 | PRIMARY KEY (id)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci"); 75 | if ($sth->execute()) 76 | { 77 | echo "\rAds Table Creation - SUCCESS"; 78 | } 79 | else 80 | { 81 | echo "\rAds Table Creation - FAILED"; 82 | } 83 | 84 | /* 85 | * Extra Ad Images Table 86 | * id - primary key. 87 | * adId - id of ad the image is tied to. 88 | * imgUrl, previewImageUrl - high and low res ad images. 89 | * createAt - image created time in UTC. 90 | * removeAt - image removed time. 91 | */ 92 | $sth = $dbo->prepare("CREATE TABLE IF NOT EXISTS images ( 93 | id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 94 | adId int(11) UNSIGNED DEFAULT 0, 95 | previewImgUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 96 | imgUrl VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', 97 | createAt int(11) UNSIGNED DEFAULT 0, 98 | removeAt int(11) UNSIGNED DEFAULT 0, 99 | PRIMARY KEY (id)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci"); 100 | if ($sth->execute()) 101 | { 102 | echo "\rImages Table Creation - SUCCESS"; 103 | } 104 | else 105 | { 106 | echo "\rImages Table Creation - FAILED"; 107 | } 108 | 109 | /* 110 | * Users Table 111 | * id - primary key. 112 | * advertisingId - unique user identifier. 113 | * accessToken - generated security token. 114 | * fcm_regid - Android FCM id. 115 | * ios_fcm_regid - iOS FCM id. 116 | * firstname, lastname, fullname, username - user data. 117 | * createAt - user creation time in UTC. 118 | * updateAt - user updated time. 119 | * u_agent - user device info. 120 | * ip_addr - user ip address. 121 | */ 122 | $sth = $dbo->prepare("CREATE TABLE IF NOT EXISTS users ( 123 | id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 124 | advertisingId varchar(50) DEFAULT '', 125 | accessToken varchar(50) DEFAULT '', 126 | gcm_regid TEXT, 127 | ios_fcm_regid TEXT, 128 | firstname VARCHAR(75) NOT NULL DEFAULT '', 129 | lastname VARCHAR(75) NOT NULL DEFAULT '', 130 | fullname VARCHAR(150) NOT NULL DEFAULT '', 131 | username VARCHAR(50) NOT NULL DEFAULT '', 132 | createAt int(11) UNSIGNED DEFAULT 0, 133 | updateAt int(11) UNSIGNED DEFAULT 0, 134 | u_agent varchar(300) DEFAULT '', 135 | ip_addr CHAR(32) NOT NULL DEFAULT '', 136 | PRIMARY KEY (id), UNIQUE KEY (advertisingId)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci"); 137 | if ($sth->execute()) 138 | { 139 | echo "\rUsers Table Creation - SUCCESS"; 140 | } 141 | else 142 | { 143 | echo "\rUsers Table Creation - FAILED"; 144 | } 145 | 146 | /* 147 | * Ad Request Log Table 148 | * id - primary key. 149 | * accountId - id of user requesting ad. 150 | * accessToken - generated security token. 151 | * createAt - ad request time in UTC. 152 | * u_agent - user device info. 153 | * ip_addr - user ip address. 154 | */ 155 | $sth = $dbo->prepare("CREATE TABLE IF NOT EXISTS access_data ( 156 | id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 157 | accountId int(11) UNSIGNED NOT NULL, 158 | accessToken varchar(50) DEFAULT '', 159 | createAt int(10) UNSIGNED DEFAULT 0, 160 | u_agent varchar(300) DEFAULT '', 161 | ip_addr CHAR(32) NOT NULL DEFAULT '', 162 | PRIMARY KEY (id)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci"); 163 | if ($sth->execute()) 164 | { 165 | echo "\rAccess Table Creation - SUCCESS"; 166 | } 167 | else 168 | { 169 | echo "\rAccess Table Creation - FAILED"; 170 | } 171 | 172 | /* 173 | * Ad Analytics Events Table 174 | * id - primary key. 175 | * accountId - id of user analytic event is tied to. 176 | * analytics_type - category type of analytics event (e.g. click, view, sale) 177 | * statId - id of ad analytic event is tied to. 178 | * statInt - integer stat value. 179 | * statText - text stat value. 180 | * notifyId - internal notification id. 181 | * createAt - analytic event created time in UTC. 182 | * removeAt - analytic event remove time. 183 | * u_agent - user device info. 184 | * ip_addr - user ip address. 185 | */ 186 | $sth = $dbo->prepare("CREATE TABLE IF NOT EXISTS analytics ( 187 | id int(11) UNSIGNED NOT NULL AUTO_INCREMENT, 188 | accountId int(11) UNSIGNED DEFAULT 0, 189 | analytics_type int(11) UNSIGNED DEFAULT 0, 190 | statId int(11) UNSIGNED DEFAULT 0, 191 | statInt int(11) UNSIGNED DEFAULT 0, 192 | statText varchar(50) DEFAULT '', 193 | notifyId int(11) UNSIGNED DEFAULT 0, 194 | createAt int(11) UNSIGNED DEFAULT 0, 195 | removeAt int(11) UNSIGNED DEFAULT 0, 196 | u_agent varchar(300) DEFAULT '', 197 | ip_addr CHAR(32) NOT NULL DEFAULT '', 198 | PRIMARY KEY (id)) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci"); 199 | if ($sth->execute()) 200 | { 201 | echo "\rAnalytics Table Creation - SUCCESS"; 202 | } 203 | else 204 | { 205 | echo "\rAnalytics Table Creation - FAILED"; 206 | } 207 | 208 | echo "\rDatabase Creation - END"; 209 | 210 | include 'sampledata.php'; 211 | 212 | } catch (Exception $e) { 213 | 214 | die ($e->getMessage()); 215 | } 216 | -------------------------------------------------------------------------------- /server/sampledata.php: -------------------------------------------------------------------------------- 1 | Sample Data Creation - START"; 5 | 6 | $currentTime = time(); 7 | $ads = new ads($dbo); 8 | 9 | 10 | $ad = array("fromUserId" => 1, 11 | "adType" => 0, 12 | "status" => 0, 13 | "segment" => "Default", 14 | "location" => "Global", 15 | "deviceVersion" => 21, 16 | "weight" => 50, 17 | "price" => 0, 18 | "title" => "Message AI - Write Better Messages (Free)", 19 | "subtitle" => "Send better, more positive messages and improve relationships 💝", 20 | "description" => "Have you ever sent a text you later regretted? Maybe you were too negative or angry at the time. Message AI warns you when you're about to send a message that could harm your relationships! 21 | 22 | In addition, Message AI helps you understand how people really feel by analyzing conversations in Messenger, WhatsApp, Tinder, Snapchat, Kik, Instagram, and Line. All messaging apps are supported! 23 | 24 | How it works: 25 | Our MessageIQ artificial intelligence analyzes your messages and shows you your Positivity Score. We score each word from -100 to 100 so you can identify positive/negative emotions. 26 | 27 | Better communication is the #1 way to improve relationships. Many people don't realize how angry they sound when tired and end up hurting the people they care about unintentionally! 28 | 29 | We're in this together 30 | Message AI is the friend that always looks out for you. We'll not only warn you if you sound negative, we'll also show you when your friends are being negative. 31 | 32 | Features: 33 | Find out if your crush likes you back ❤️ 34 | Who secretly likes you? Discover your secret admirers 😙 35 | Monitor your relationship with artificial intelligence! 36 | Be more positive and increase your likability 🔥 37 | Identify passive aggressiveness so you can defuse toxic situations. 38 | Uncover hidden attitudes people have. How do people REALLY feel? 39 | Pick up on warning signals that someone's about to ghost you with AI 👻 40 | Build better relationships with improve communication. 41 | Be a better friend and more positive person!", 42 | "descriptionShort" => "Message AI helps you sound more positive in your messages, increasing your likability and improving relationships 💝", 43 | "category" => "Social", 44 | "rating" => 5.0, 45 | "installs" => 500, 46 | "version" => "0.9.4", 47 | "developer" => "Straight Up", 48 | "email" => "support@messageai.co", 49 | "address" => "Kansas City, Kansas", 50 | "website" => "http://messageai.co", 51 | "linkUrl" => "https://play.google.com/store/apps/details?id=ai.message.lite", 52 | "packageName" => "ai.message.lite", 53 | "previewImgUrl" => "https://lh3.googleusercontent.com/5wtW75qqbqk1-iprBeW4hAxy6iw56zX6EQ8mRBfoUlWWZtxYDpvtZw8EnjpdjJ7VnAUg=s128-rw", 54 | "imgUrl" => "https://lh3.googleusercontent.com/5wtW75qqbqk1-iprBeW4hAxy6iw56zX6EQ8mRBfoUlWWZtxYDpvtZw8EnjpdjJ7VnAUg=s256-rw", 55 | "previewVideoImgUrl" => "https://lh3.googleusercontent.com/gTxlSPIPzfe1NoBsryU5dkw5I9kuJRE6RsznCWav76MaoKHfm0YwbD7oF4AbuAxe6QE=w360", 56 | "videoUrl" => "", 57 | "text1" => "", 58 | "text2" => "", 59 | "text3" => "", 60 | "number1" => 0, 61 | "number2" => 0, 62 | "number3" => 0, 63 | "startAt" => $currentTime, 64 | "endAt" => 2000000000); 65 | $ads->add($ad); 66 | unset($ad); 67 | 68 | $ad = array("fromUserId" => 1, 69 | "adType" => 0, 70 | "status" => 0, 71 | "segment" => "Default", 72 | "location" => "Global", 73 | "deviceVersion" => 21, 74 | "weight" => 49, 75 | "price" => 0, 76 | "title" => "Crowdfunding Projects", 77 | "subtitle" => "Browse all crowdfunding projects in one app!", 78 | "description" => "What's inside? 79 | ✓ Crowdfunding Community - join the best crowdfunding community today! 80 | ✓ Top Project Feed - all crowdfunding projects from Kickstarter and Indiegogo ranked by popularity! 81 | ✓ Latest Projects Feed - find the newest projects here first. 82 | ✓ Vote on projects to level up and earn cool rewards. 83 | ✓ Comments - discuss projects with the crowdfunding community. 84 | ✓ Leaderboards - track your crowdfunding score and compete to be the top crowdfunder! 85 | ✓ Submit new crowdfunding projects. 86 | 87 | App Features: 88 | ☆ Native Android app w/smooth and elegant design. 89 | ☆ Personalizable profile page. 90 | ☆ Real time voting and commenting platform. 91 | ☆ In-app messaging to chat with other crowdfunders. 92 | ☆ Integrated browser to view projects without leaving the app. 93 | 94 | ★ Where you can find us: 95 | Web - http://crowdfunding.stream/ 96 | Twitter - http://twitter.com/crowdfunding 97 | Email - admin@crowdfunding.stream", 98 | "descriptionShort" => "Browse all crowdfunding projects from Kickstarter and Indiegogo in one app! Built by crowdfunding enthusiasts, Crowdfunding Projects is the place to share and talk about the hottest new crowdfunding projects with fellow crowdfunding addicts.", 99 | "category" => "Social", 100 | "rating" => 5.0, 101 | "installs" => 10000, 102 | "version" => "4.3.1", 103 | "developer" => "Stream Inc", 104 | "email" => "admin@crowdfunding.stream", 105 | "address" => "Kansas City, Kansas", 106 | "website" => "http://crowdfunding.stream", 107 | "linkUrl" => "https://play.google.com/store/apps/details?id=io.ideastarter", 108 | "packageName" => "io.ideastarter", 109 | "previewImgUrl" => "http://lh3.googleusercontent.com/R-vJInTblK1KBOqZaSDm_ac270QBHsiIcU9agHnN-rrp9K_lkN8rLzGIH8asCfkb420Q=w128-rw", 110 | "imgUrl" => "http://lh3.googleusercontent.com/R-vJInTblK1KBOqZaSDm_ac270QBHsiIcU9agHnN-rrp9K_lkN8rLzGIH8asCfkb420Q=w256-rw", 111 | "previewVideoImgUrl" => "https://lh3.googleusercontent.com/3coPDBP3zFcy0vriR2rhVn8BbpxIk_iXUOMzhLGHeIx35ZJ_JfyytshxvFt1QrVgnwc=h360-rw", 112 | "videoUrl" => "", 113 | "text1" => "", 114 | "text2" => "", 115 | "text3" => "", 116 | "number1" => 0, 117 | "number2" => 0, 118 | "number3" => 0, 119 | "startAt" => $currentTime, 120 | "endAt" => 2000000000); 121 | $ads->add($ad); 122 | unset($ad); 123 | 124 | $ad = array("fromUserId" => 1, 125 | "adType" => 0, 126 | "status" => 0, 127 | "segment" => "Default", 128 | "location" => "Global", 129 | "deviceVersion" => 15, 130 | "weight" => 48, 131 | "price" => 0, 132 | "title" => "Rocket Notes", 133 | "subtitle" => "The World's Fastest Note Taking App!", 134 | "description" => "Rocket Notes Features: 135 | 🚀 Creating a new note is as easy as typing a text message! 136 | 🚀 Just start writing and Rocket Note will do the rest. 137 | 🚀 Notes are saved automatically. 138 | 🚀 Minimalistic - no more worrying about formatting or how the note looks. 139 | 🚀 Taking a note is easy; leave the fonts, colors, and bold/italics to Microsoft Word. 140 | 🚀 Recent notes are always visible from your home screen and never more than ONE tap away. 141 | 🚀 No more opening an app to take notes; just start writing instead! 142 | 143 | Rocket Images Features: 144 | ☆ Forget writing, snap a picture instead! 145 | ☆ Recent photo notes are displayed in a home screen gallery and instantly visible. 146 | ☆ Image notes are only ONE tap away! 147 | ☆ Tapping on a thumbnail opens the picture in full screen mode for viewing and sharing. 148 | ☆ Photos are stored separate from your gallery app. 149 | ☆ No more searching for important notes buried under your selfies, having work documents show up in your slideshows, or getting boring images backed up via Google Photos. 150 | 151 | Rocket Share Features: 152 | ✓ Share text and images directly to Rocket Notes. 153 | ✓ Does not interrupt what you are doing. 154 | ✓ Image URLs shared to the app are automatically downloaded! 155 | 156 | ★ Where you can find us: ★ 157 | Twitter - http://twitter.com/rayliverified", 158 | "descriptionShort" => "Fast. Simple. Create a note in one tap! Create image and text notes directly from your home screen!", 159 | "category" => "Productivity", 160 | "rating" => 5.0, 161 | "installs" => 500, 162 | "version" => "1.5.0", 163 | "developer" => "Stream Inc", 164 | "email" => "admin@apprewards.org", 165 | "address" => "Kansas City, Kansas", 166 | "website" => "http://apprewards.org/rocketnotes/index.html", 167 | "linkUrl" => "https://play.google.com/store/apps/details?id=stream.rocketnotes", 168 | "packageName" => "stream.rocketnotes", 169 | "previewImgUrl" => "https://lh3.googleusercontent.com/tYGJBG8mc7lwC0ZxQUxif2FVMFI8L8xRkPON0ytkWVPTI67ggkrgDl3JpRu9jW0W3sLJ=w128-rw", 170 | "imgUrl" => "https://lh3.googleusercontent.com/tYGJBG8mc7lwC0ZxQUxif2FVMFI8L8xRkPON0ytkWVPTI67ggkrgDl3JpRu9jW0W3sLJ=w256-rw", 171 | "previewVideoImgUrl" => "https://lh3.googleusercontent.com/s1IcJ6DUCPUgl2ZxGLqld8ROsARVBPDemnsfcfda0vJ8SQsoAOmbinTCcqpFfc48IA=h360-rw", 172 | "videoUrl" => "", 173 | "text1" => "", 174 | "text2" => "", 175 | "text3" => "", 176 | "number1" => 0, 177 | "number2" => 0, 178 | "number3" => 0, 179 | "startAt" => $currentTime, 180 | "endAt" => 2000000000); 181 | $ads->add($ad); 182 | unset($ad); 183 | 184 | $ad = array("fromUserId" => 1, 185 | "adType" => 0, 186 | "status" => 0, 187 | "segment" => "Default", 188 | "location" => "Global", 189 | "deviceVersion" => 15, 190 | "weight" => 47, 191 | "price" => 0, 192 | "title" => "Doodle Donut", 193 | "subtitle" => "Play the yummiest arcade game ever!", 194 | "description" => "Gameplay Highlights: 195 | ✓ Satisfy your donut cravings without gaining a single pound! 196 | ✓ Feast on visually delightful doodle art! 197 | ✓ Experience classic arcade style gameplay! 198 | ✓ Fight against mouthwatering donuts! 199 | ✓ Collect refreshing coffees and level up! 200 | ✓ Test your reflexes with daring acrobatic maneuvers! 201 | ✓ Realistic donut calorie counts! 202 | ✓ Help Tummy Yummy™ burn calories and lose weight! 203 | 204 | Game Features: 205 | ☆ Enjoy beautiful high definition doodle art 206 | ☆ Fabulously fluid 60 FPS action 207 | ☆ No personal information collected, safe for kids! 208 | ☆ Impressively intuitive and responsive controls 209 | ☆ Discover over 12 flavor-filled donuts 210 | ☆ Uncover new donut powers 211 | ☆ Unlock over 30 achievements 212 | ☆ Compete in global leaderboards 213 | ☆ Track realistic calorie counts and number of donuts ate 214 | ☆ Relax in the coffee store with great music 215 | ☆ Can you discover all the easter eggs? 216 | 217 | ★ Where you can find us: 218 | Web - http://apprewards.org/doodledonut/index.html 219 | Twitter - http://twitter.com/rayliverified", 220 | "descriptionShort" => "Jump to battle tasty donuts and drink delicious coffees in the most action-packed donut game ever! Start your coffee fueled adventure today and jump as high as you can in the yummiest game ever!", 221 | "category" => "Arcade", 222 | "rating" => 5.0, 223 | "installs" => 500, 224 | "version" => "6.0", 225 | "developer" => "Stream Inc", 226 | "email" => "admin@apprewards.org", 227 | "address" => "Kansas City, Kansas", 228 | "website" => "http://apprewards.org/doodledonut/index.html", 229 | "linkUrl" => "https://play.google.com/store/apps/details?id=com.DoodleDonut", 230 | "packageName" => "com.DoodleDonut", 231 | "previewImgUrl" => "https://lh3.googleusercontent.com/L2veVvuA8k1yjpYQj7hxb1yocpGgt-lvFEfpzMYCqPUsTwZihcev2pg5zkeBD3ChrSI=w128-rw", 232 | "imgUrl" => "https://lh3.googleusercontent.com/L2veVvuA8k1yjpYQj7hxb1yocpGgt-lvFEfpzMYCqPUsTwZihcev2pg5zkeBD3ChrSI=w256-rw", 233 | "previewVideoImgUrl" => "https://lh3.googleusercontent.com/cq0RTFJCsoRqujcSA64kzqJr2tO9U5n8XsypMFRITq8oB2ui_8N09DpzGsYfFiG4W_Y=h360-rw", 234 | "videoUrl" => "", 235 | "text1" => "", 236 | "text2" => "", 237 | "text3" => "", 238 | "number1" => 0, 239 | "number2" => 0, 240 | "number3" => 0, 241 | "startAt" => $currentTime, 242 | "endAt" => 2000000000); 243 | $ads->add($ad); 244 | unset($ad); 245 | 246 | $ad = array("fromUserId" => 1, 247 | "adType" => 0, 248 | "status" => 0, 249 | "segment" => "Default", 250 | "location" => "Global", 251 | "deviceVersion" => 15, 252 | "weight" => 46, 253 | "price" => 0, 254 | "title" => "Blank Icon/Widget", 255 | "subtitle" => "100% transparent app icon and widgets.", 256 | "description" => "Amazing Features: 257 | ✓ Most blank and transparent app in the app store 258 | ✓ Invisible app icon and widget 259 | ✓ Blank Widgets help customize homescreen 260 | ✓ Use blank icons as placeholders to add additional screens to your launcher 261 | ✓ Prevent newly installed apps from messing up your app layout 262 | ✓ Prank your friends by placing invisible widgets on their homescreen 263 | 264 | NOTE: The new Adaptive Icons introduced in Android Oreo makes the app icon white and not transparent. The only way to create a blank icon placeholder is to use Blank Widgets. (applies to Android 8.0+ and Samsung users) 265 | 266 | ★ Where you can find us: 267 | Twitter - http://twitter.com/rayliverified", 268 | "descriptionShort" => "Blank Icon is a completely transparent app icon for homescreen customization and testing purposes. Blank Icon also includes Blank Widgets that can be used to customize the homescreen. Check out these amazing features!", 269 | "category" => "Tools", 270 | "rating" => 5.0, 271 | "installs" => 10000, 272 | "version" => "2.3.2", 273 | "developer" => "Stream Inc", 274 | "email" => "Kansas City, Kansas", 275 | "address" => "801 Eldridge St.", 276 | "website" => "http://apprewards.org/blankicon/index.html", 277 | "linkUrl" => "https://play.google.com/store/apps/details?id=com.blankicon", 278 | "packageName" => "com.blankicon", 279 | "previewImgUrl" => "https://lh3.googleusercontent.com/CT1M2pKlUhGx4w5UHqarn6oSU_sa7L7XRW2-hQrfNi9oou6W81PbJnWi-9PbEfC_3g=w128-rw", 280 | "imgUrl" => "https://lh3.googleusercontent.com/CT1M2pKlUhGx4w5UHqarn6oSU_sa7L7XRW2-hQrfNi9oou6W81PbJnWi-9PbEfC_3g=w256-rw", 281 | "previewVideoImgUrl" => "https://lh3.googleusercontent.com/JMQxI2HkyWvWMgeBmVg7cUOsoqdym5lnxEjKQeZ8D0wTqe2UFJRGklJT-_dQXVlNJPeg=h360-rw", 282 | "videoUrl" => "", 283 | "text1" => "", 284 | "text2" => "", 285 | "text3" => "", 286 | "number1" => 0, 287 | "number2" => 0, 288 | "number3" => 0, 289 | "startAt" => $currentTime, 290 | "endAt" => 2000000000); 291 | $ads->add($ad); 292 | unset($ad); 293 | 294 | echo "\rSample Data Creation - END"; 295 | 296 | } catch (Exception $e) { 297 | 298 | die ($e->getMessage()); 299 | } 300 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':crosspromotion' 2 | --------------------------------------------------------------------------------