Repository: thiagokimo/Faker Branch: master Commit: 8b0eccd49981 Files: 108 Total size: 323.8 KB Directory structure: gitextract_z0fqpsma/ ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── io/ │ │ └── kimo/ │ │ └── faker/ │ │ ├── FakerApp.java │ │ ├── mvp/ │ │ │ ├── BasePresenter.java │ │ │ ├── BaseView.java │ │ │ ├── Presenter.java │ │ │ ├── View.java │ │ │ ├── presenter/ │ │ │ │ ├── AddressPresenter.java │ │ │ │ ├── ColorPresenter.java │ │ │ │ ├── InternetPresenter.java │ │ │ │ ├── LoremPresenter.java │ │ │ │ ├── NamePresenter.java │ │ │ │ ├── NumberPresenter.java │ │ │ │ ├── PhonePresenter.java │ │ │ │ └── UrlPresenter.java │ │ │ └── view/ │ │ │ ├── AddressView.java │ │ │ ├── ColorView.java │ │ │ ├── InternetView.java │ │ │ ├── LoremView.java │ │ │ ├── NameView.java │ │ │ ├── NumberView.java │ │ │ ├── PhoneView.java │ │ │ └── UrlView.java │ │ └── ui/ │ │ ├── activity/ │ │ │ └── MainActivity.java │ │ └── fragment/ │ │ ├── AddressFragment.java │ │ ├── ColorFragment.java │ │ ├── InternetFragment.java │ │ ├── LoremFragment.java │ │ ├── NameFragment.java │ │ ├── NumberFragment.java │ │ ├── PhoneFragment.java │ │ ├── ProfileFragment.java │ │ ├── TargetViewsFragment.java │ │ ├── UrlFragment.java │ │ └── WidgetsFragment.java │ └── res/ │ ├── layout/ │ │ ├── activity_with_toolbar.xml │ │ ├── fragment_address.xml │ │ ├── fragment_color.xml │ │ ├── fragment_internet.xml │ │ ├── fragment_lorem.xml │ │ ├── fragment_name.xml │ │ ├── fragment_number.xml │ │ ├── fragment_phone.xml │ │ ├── fragment_profile.xml │ │ ├── fragment_target_views.xml │ │ ├── fragment_url.xml │ │ ├── fragment_widgets.xml │ │ ├── header_drawer.xml │ │ └── view_loading.xml │ ├── menu/ │ │ └── menu_main.xml │ ├── values/ │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ ├── values-v21/ │ │ └── styles.xml │ └── values-w820dp/ │ └── dimens.xml ├── build.gradle ├── faker-core/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── io/ │ │ └── kimo/ │ │ └── lib/ │ │ └── faker/ │ │ └── component/ │ │ ├── number/ │ │ │ └── NumberComponentTest.java │ │ └── text/ │ │ ├── AddressComponentTest.java │ │ ├── InternetComponentTest.java │ │ ├── LoremComponentTest.java │ │ ├── NameComponentTest.java │ │ ├── PhoneComponentTest.java │ │ └── UrlComponentTest.java │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ └── io/ │ │ └── kimo/ │ │ └── lib/ │ │ └── faker/ │ │ ├── Faker.java │ │ ├── FakerCoreComponent.java │ │ ├── api/ │ │ │ ├── AddressAPI.java │ │ │ ├── ColorAPI.java │ │ │ ├── InternetAPI.java │ │ │ ├── LoremAPI.java │ │ │ ├── NameAPI.java │ │ │ ├── NumberAPI.java │ │ │ ├── PhoneAPI.java │ │ │ └── UrlAPI.java │ │ └── component/ │ │ ├── FakerColorComponent.java │ │ ├── FakerNumericComponent.java │ │ ├── FakerTextComponent.java │ │ ├── number/ │ │ │ ├── ColorComponent.java │ │ │ └── NumberComponent.java │ │ └── text/ │ │ ├── AddressComponent.java │ │ ├── InternetComponent.java │ │ ├── LoremComponent.java │ │ ├── NameComponent.java │ │ ├── PhoneComponent.java │ │ └── URLComponent.java │ └── res/ │ └── values/ │ ├── address.xml │ ├── internet.xml │ ├── lorem.xml │ ├── names.xml │ ├── phones.xml │ └── strings.xml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── maven_push.gradle └── settings.gradle ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Built application files *.apk *.ap_ # Files for the Dalvik VM *.dex # Java class files *.class # Generated files bin/ gen/ # Gradle files .gradle/ build/ /*/build/ # Local configuration file (sdk path, etc) local.properties # Proguard folder generated by Eclipse proguard/ # Log Files *.log *.iml .idea/ .DS_Store ================================================ FILE: .travis.yml ================================================ language: android jdk: oraclejdk7 env: global: - ADB_INSTALL_TIMEOUT=8 env: matrix: - ANDROID_TARGET=10 ANDROID_ABI=default/armeabi - ANDROID_TARGET=21 ANDROID_ABI=default/armeabi-v7a android: components: - android-22 - build-tools-22.0.1 - extra-android-m2repository before_script: - echo no | android create avd --force -n test -t android-$ANDROID_TARGET --abi $ANDROID_ABI - emulator -avd test -no-skin -no-audio -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & script: - ./gradlew clean assemble -PdisablePreDex -q - ./gradlew connectedAndroidTest ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # Faker [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Faker-green.svg?style=flat)](https://android-arsenal.com/details/1/2039) [![Build Status](https://travis-ci.org/thiagokimo/Faker.svg?branch=master)](https://travis-ci.org/thiagokimo/Faker) Faker provides fake data to your Android MPVs. Now it's very handy to make screenshots of your apps without worrying with Google Play copyright infringments, e.g [this app](https://play.google.com/store/apps/details?id=io.kimo.tmdb). Faker helps you to populate your views with random data quickly and painlessly. ## Screenshots ![](https://raw.githubusercontent.com/thiagokimo/Faker/master/screenshots/random-data.png) ![](https://raw.githubusercontent.com/thiagokimo/Faker/master/screenshots/profile-sample-screenshot.png) ## Demo The sample application (the source is in the **app** folder) has been published on Google Play to facilitate the access: [![Get it on Google Play](http://www.android.com/images/brand/get_it_on_play_logo_small.png)](https://play.google.com/store/apps/details?id=io.kimo.faker) The demo app has a very clean MVP architecture based in the idea of [this post](http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/). Feel free to give me suggestions. ## Setup Gradle: Add the JitPack repository to your build file: ``` groovy repositories { maven { url "https://jitpack.io" } } ``` Add the dependency in the form: ``` groovy dependencies { compile 'com.github.thiagokimo:faker:VERSION' } ``` Maven: If you use Maven, add this into your build file: ``` xml jitpack.io https://jitpack.io ``` ``` xml com.github.thiagokimo faker VERSION ``` ## Usage ### The "lazy" way ``` java Faker.with(context) .fill(rootView); ``` Faker will figure out all views inside the one you passed to it and fill it with proper data. Just like that! By default faker will fill **TextViews** with lorem ipsum, **ImageViews** with a random color, **CompoundButtons** with a random state (check or uncheck) and **ProgressBars** with a random progress value. ### The specific way ``` java Faker.with(context) .NameOfTheComponent .componentMethod(); ``` ### Targeting views If you want Faker to fill specific views inside your ViewGroup you can pass your target views like the example below ``` java Faker.with(context) .targetViews(collection-of-ids) .fill(rootView); ``` Check out all examples [here](https://github.com/thiagokimo/Faker/tree/master/app/src/main/java/io/kimo/faker/mvp/presenter). ## Components Faker is organized in components that provides you specific types of data. Here is a list of the current components: * [Lorem](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/text/LoremComponent.java) - The old good lorem ispum words, sentences and paragraphs. * [Name](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/text/NameComponent.java) - Firsts, lasts, full and complete names and profession/titles. * [Number](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/number/NumberComponent.java) - It gives you numbers ¬¬ * [Phone](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/text/PhoneComponent.java) - Phone masks \o/ * [Internet](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/text/InternetComponent.java) - It provides you random emails and domains. * [Url](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/text/URLComponent.java) - Gives you (valid) urls that you might use somewhere. * [Color](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/number/ColorComponent.java) - Generates attractive colors thanks to [lzyzsd](https://github.com/lzyzsd/AndroidRandomColor)! * [Address](https://github.com/thiagokimo/Faker/blob/master/faker-core/src/main/java/io/kimo/lib/faker/component/text/AddressComponent.java) - Gives random cities, countries, zipcodes, states and so on. ## Contribuiting 1. Fork it 2. Create your feature/bug-fix branch(`git checkout -b my-new-feature-or-fix`) 3. Commit your changes (`git commit -am 'Add some feature/fix'`) 4. Do your pull-request Make sure you write tests for your code. Only code with passing tests will be accepted. ### Components You can add more components or improve the existing ones. For new components, make sure you also add an example in the demo app. ### Localization You can help providing localized data to Faker components. ## License Copyright 2011, 2012 Thiago Rocha Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion '26.0.0' defaultConfig { applicationId "io.kimo.faker" minSdkVersion 14 targetSdkVersion 22 versionCode 8 versionName "1.0.7" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile('com.mikepenz:materialdrawer:3.0.8@aar') { transitive = true } compile('com.mikepenz:aboutlibraries:5.0.5@aar') { transitive = true } compile 'com.squareup.picasso:picasso:2.5.2' compile project(':faker-core') } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Users/Kimo/android-sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/java/io/kimo/faker/FakerApp.java ================================================ package io.kimo.faker; import android.app.Application; public class FakerApp extends Application { } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/BasePresenter.java ================================================ package io.kimo.faker.mvp; import android.content.Context; public abstract class BasePresenter implements Presenter { protected View view; protected Context context; public BasePresenter(View view, Context context) { this.view = view; this.context = context; } @Override public void createView() { hideAllViews(); view.showLoading(); configureMainView(); view.hideLoading(); view.showView(); } public void hideAllViews() { view.hideView(); view.hideLoading(); } public abstract void configureMainView(); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/BaseView.java ================================================ package io.kimo.faker.mvp; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public abstract class BaseView extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(getLayoutResource(), container, false); mapGUI(view); configureGUI(); return view; } @Override public void onStart() { super.onStart(); startPresenter(); } @Override public void onStop() { super.onStop(); stopPresenter(); } public abstract int getLayoutResource(); public abstract void mapGUI(View view); public abstract void configureGUI(); public abstract void startPresenter(); public abstract void stopPresenter(); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/Presenter.java ================================================ package io.kimo.faker.mvp; public interface Presenter { void createView(); void destroyView(); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/View.java ================================================ package io.kimo.faker.mvp; public interface View { void showFeedback(String msg); void showView(); void hideView(); void showLoading(); void hideLoading(); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/AddressPresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.AddressView; import io.kimo.lib.faker.Faker; public class AddressPresenter extends BasePresenter{ public AddressPresenter(AddressView view, Context context) { super(view, context); } @Override public void configureMainView() { AddressView addressView = (AddressView) view; addressView.updateCityExample(Faker.with(context).Address.city()); addressView.updateStreetExample(Faker.with(context).Address.street()); addressView.updateSecondaryAddressExample(Faker.with(context).Address.secondaryAddress()); addressView.updateZipcodeExample(Faker.with(context).Address.zipCode()); addressView.updateTimezoneExample(Faker.with(context).Address.timeZone()); addressView.updateCityPrefixExample(Faker.with(context).Address.cityPrefix()); addressView.updateCitySuffixExample(Faker.with(context).Address.citySuffix()); addressView.updateStateExample(Faker.with(context).Address.state()); addressView.updateStateAbbrvExample(Faker.with(context).Address.stateAbbreviation()); addressView.updateCountryExample(Faker.with(context).Address.country()); addressView.updateCountryAbbrvExample(Faker.with(context).Address.countryAbbreviation()); addressView.updateLatitudeExample(Faker.with(context).Address.latitude()); addressView.updateLongitudeExample(Faker.with(context).Address.longitude()); } @Override public void destroyView() { } } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/ColorPresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.ColorView; import io.kimo.lib.faker.Faker; public class ColorPresenter extends BasePresenter{ public ColorPresenter(ColorView view, Context context) { super(view, context); } @Override public void configureMainView() { ColorView colorView = (ColorView) view; colorView.updateRandomColorExample(Faker.with(context).Color.randomColor()); colorView.updateRedColorExample(Faker.with(context).Color.redColor()); colorView.updateGreenColorExample(Faker.with(context).Color.greenColor()); colorView.updateBlueColorExample(Faker.with(context).Color.blueColor()); colorView.updateMonochromeColorExample(Faker.with(context).Color.monochromeColor()); colorView.updateBrightColorExample(Faker.with(context).Color.brightColor()); colorView.updateDarkColorExample(Faker.with(context).Color.darkColor()); colorView.updateLightColorExample(Faker.with(context).Color.lightColor()); } @Override public void destroyView() { } } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/InternetPresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.InternetView; import io.kimo.lib.faker.Faker; public class InternetPresenter extends BasePresenter{ public InternetPresenter(InternetView view, Context context) { super(view, context); } @Override public void configureMainView() { InternetView internetView = (InternetView) view; internetView.updateEmailExample(Faker.with(context).Internet.email()); internetView.updateURLExample(Faker.with(context).Internet.url()); internetView.updateDomainExample(Faker.with(context).Internet.domain()); internetView.updateDomainSuffixExample(Faker.with(context).Internet.domainSuffix()); } @Override public void destroyView() {} } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/LoremPresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.LoremView; import io.kimo.lib.faker.Faker; public class LoremPresenter extends BasePresenter { public LoremPresenter(LoremView view, Context context) { super(view, context); } @Override public void configureMainView() { LoremView loremView = (LoremView) view; loremView.updateCharacterExample(Faker.with(context).Lorem.character()); loremView.updateCharactersExample(Faker.with(context).Lorem.characters()); loremView.updateWordExample(Faker.with(context).Lorem.word()); loremView.updateWordsExample(Faker.with(context).Lorem.words()); loremView.updateSentenceExample(Faker.with(context).Lorem.sentence()); loremView.updateSentencesExample(Faker.with(context).Lorem.sentences()); loremView.updateParagraphExample(Faker.with(context).Lorem.paragraph()); loremView.updateParagraphsExample(Faker.with(context).Lorem.paragraphs()); } @Override public void destroyView() {} } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/NamePresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.NameView; import io.kimo.lib.faker.Faker; public class NamePresenter extends BasePresenter { public NamePresenter(NameView view, Context context) { super(view, context); } @Override public void configureMainView() { NameView nameView = (NameView) view; nameView.updateCompleteNameExample(Faker.with(context).Name.completeName()); nameView.updateFullNameExample(Faker.with(context).Name.fullName()); nameView.updateFirstNameExample(Faker.with(context).Name.firstName()); nameView.updateLastNameExample(Faker.with(context).Name.lastName()); nameView.updatePrefixExample(Faker.with(context).Name.prefix()); nameView.updateSuffixExample(Faker.with(context).Name.suffix()); nameView.updateTitleExample(Faker.with(context).Name.title()); } @Override public void destroyView() {} } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/NumberPresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.NumberView; import io.kimo.lib.faker.Faker; public class NumberPresenter extends BasePresenter { public NumberPresenter(NumberView view, Context context) { super(view, context); } @Override public void configureMainView() { NumberView numberView = (NumberView) view; numberView.updateDigit(Faker.with(context).Number.digit()); numberView.updatePositiveDigit(Faker.with(context).Number.positiveDigit()); numberView.updateNegativeDigit(Faker.with(context).Number.negativeDigit()); numberView.updateNumbers(Faker.with(context).Number.number()); numberView.updatePositiveNumbers(Faker.with(context).Number.positiveNumber()); numberView.updateNegativeNumbers(Faker.with(context).Number.negativeNumber()); } @Override public void destroyView() {} } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/PhonePresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.View; import io.kimo.faker.mvp.view.PhoneView; import io.kimo.lib.faker.Faker; public class PhonePresenter extends BasePresenter { public PhonePresenter(View view, Context context) { super(view, context); } @Override public void configureMainView() { PhoneView phoneView = (PhoneView) view; phoneView.updatePhoneWithAreaCodeExample(Faker.with(context).Phone.phoneWithAreaCode()); phoneView.updatePhoneWithCountryCodeExample(Faker.with(context).Phone.phoneWithCountryCode()); } @Override public void destroyView() {} } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/presenter/UrlPresenter.java ================================================ package io.kimo.faker.mvp.presenter; import android.content.Context; import io.kimo.faker.mvp.BasePresenter; import io.kimo.faker.mvp.view.UrlView; import io.kimo.lib.faker.Faker; public class UrlPresenter extends BasePresenter{ public UrlPresenter(UrlView view, Context context) { super(view, context); } @Override public void configureMainView() { UrlView urlView = (UrlView) view; urlView.updateImageUrlExample(Faker.with(context).Url.image()); urlView.updateAvatarUrlExample(Faker.with(context).Url.avatar()); } @Override public void destroyView() { } } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/AddressView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface AddressView extends View { void updateCityExample(String value); void updateStreetExample(String value); void updateSecondaryAddressExample(String value); void updateZipcodeExample(String value); void updateTimezoneExample(String value); void updateCityPrefixExample(String value); void updateCitySuffixExample(String value); void updateStateExample(String value); void updateStateAbbrvExample(String value); void updateCountryExample(String value); void updateCountryAbbrvExample(String value); void updateLatitudeExample(String value); void updateLongitudeExample(String value); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/ColorView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface ColorView extends View { void updateRandomColorExample(int color); void updateRedColorExample(int color); void updateGreenColorExample(int color); void updateBlueColorExample(int color); void updateMonochromeColorExample(int color); void updateBrightColorExample(int color); void updateLightColorExample(int color); void updateDarkColorExample(int color); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/InternetView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface InternetView extends View { void updateEmailExample(String value); void updateURLExample(String value); void updateDomainExample(String value); void updateDomainSuffixExample(String value); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/LoremView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface LoremView extends View { void updateCharacterExample(String value); void updateCharactersExample(String value); void updateWordExample(String value); void updateWordsExample(String value); void updateSentenceExample(String value); void updateSentencesExample(String value); void updateParagraphExample(String value); void updateParagraphsExample(String value); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/NameView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface NameView extends View { void updateCompleteNameExample(String value); void updateFullNameExample(String value); void updateFirstNameExample(String value); void updateLastNameExample(String value); void updatePrefixExample(String value); void updateSuffixExample(String value); void updateTitleExample(String value); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/NumberView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface NumberView extends View { void updateDigit(int value); void updatePositiveDigit(int value); void updateNegativeDigit(int value); void updateNumbers(int value); void updatePositiveNumbers(int value); void updateNegativeNumbers(int value); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/PhoneView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface PhoneView extends View { void updatePhoneWithAreaCodeExample(String value); void updatePhoneWithCountryCodeExample(String value); } ================================================ FILE: app/src/main/java/io/kimo/faker/mvp/view/UrlView.java ================================================ package io.kimo.faker.mvp.view; import io.kimo.faker.mvp.View; public interface UrlView extends View { void updateImageUrlExample(String value); void updateAvatarUrlExample(String value); } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/activity/MainActivity.java ================================================ package io.kimo.faker.ui.activity; import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ScrollView; import com.mikepenz.aboutlibraries.Libs; import com.mikepenz.aboutlibraries.LibsBuilder; import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.iconics.IconicsDrawable; import com.mikepenz.materialdrawer.Drawer; import com.mikepenz.materialdrawer.DrawerBuilder; import com.mikepenz.materialdrawer.model.PrimaryDrawerItem; import com.mikepenz.materialdrawer.model.SectionDrawerItem; import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; import io.kimo.faker.R; import io.kimo.faker.ui.fragment.AddressFragment; import io.kimo.faker.ui.fragment.ColorFragment; import io.kimo.faker.ui.fragment.InternetFragment; import io.kimo.faker.ui.fragment.LoremFragment; import io.kimo.faker.ui.fragment.NameFragment; import io.kimo.faker.ui.fragment.NumberFragment; import io.kimo.faker.ui.fragment.PhoneFragment; import io.kimo.faker.ui.fragment.ProfileFragment; import io.kimo.faker.ui.fragment.TargetViewsFragment; import io.kimo.faker.ui.fragment.UrlFragment; import io.kimo.faker.ui.fragment.WidgetsFragment; public class MainActivity extends AppCompatActivity { public static final int LOREM_FRAGMENT = 0; public static final int NAME_FRAGMENT = 1; public static final int NUMBER_FRAGMENT = 2; public static final int PHONE_FRAGMENT = 3; public static final int INTERNET_FRAGMENT = 4; public static final int URL_FRAGMENT = 5; public static final int PROFILE_FRAGMENT = 6; public static final int RANDOM_WIDGETS_FRAGMENT = 7; public static final int COLOR_FRAGMENT = 8; public static final int ADDRESS_FRAGMENT = 9; public static final int TARGET_VIEWS_FRAGMENT = 10; private Toolbar toolbar; private Drawer drawer; private ScrollView scrollView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_with_toolbar); configureToolbar(); configureDrawer(savedInstanceState); if(savedInstanceState == null) { showFragment(RANDOM_WIDGETS_FRAGMENT); } } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_main, menu); MenuItem menuItem = menu.findItem(R.id.action_about); menuItem.setIcon(new IconicsDrawable(this, GoogleMaterial.Icon.gmd_info_outline).actionBar().color(Color.WHITE)); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_about: new LibsBuilder() .withFields(R.string.class.getFields()) .withAutoDetect(true) .withAboutIconShown(true) .withAboutVersionShownName(true) .withAboutAppName("Faker") .withAboutDescription("Provides fake data to your Android apps.") .withActivityTitle("About") .withActivityTheme(R.style.AppTheme) .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR) .start(this); return true; } return super.onOptionsItemSelected(item); } private void configureToolbar() { toolbar = (Toolbar) findViewById(R.id.toolbar); if(toolbar != null) { setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } } private void configureDrawer(Bundle savedInstanceState) { drawer = new DrawerBuilder() .withActivity(this) .withHeader(R.layout.header_drawer) .withToolbar(toolbar) .withTranslucentStatusBar(true) .addDrawerItems( new PrimaryDrawerItem().withName("Random data").withIdentifier(RANDOM_WIDGETS_FRAGMENT), new PrimaryDrawerItem().withName("Target views").withIdentifier(TARGET_VIEWS_FRAGMENT), new PrimaryDrawerItem().withName("\"Specific\" random data").withIdentifier(PROFILE_FRAGMENT), new SectionDrawerItem().withName("FAKER COMPONENTS"), new PrimaryDrawerItem() .withName("Lorem") .withIcon(GoogleMaterial.Icon.gmd_text_format) .withIconTintingEnabled(true) .withIdentifier(LOREM_FRAGMENT), new PrimaryDrawerItem() .withName("Name") .withIcon(GoogleMaterial.Icon.gmd_person) .withIconTintingEnabled(true) .withIdentifier(NAME_FRAGMENT), new PrimaryDrawerItem() .withName("Number") .withIcon(GoogleMaterial.Icon.gmd_filter_9_plus) .withIconTintingEnabled(true) .withIdentifier(NUMBER_FRAGMENT), new PrimaryDrawerItem() .withName("Phone") .withIcon(GoogleMaterial.Icon.gmd_call) .withIconTintingEnabled(true) .withIdentifier(PHONE_FRAGMENT), new PrimaryDrawerItem() .withName("Internet") .withIcon(GoogleMaterial.Icon.gmd_public) .withIconTintingEnabled(true) .withIdentifier(INTERNET_FRAGMENT), new PrimaryDrawerItem() .withName("Url") .withIcon(GoogleMaterial.Icon.gmd_photo) .withIconTintingEnabled(true) .withIdentifier(URL_FRAGMENT), new PrimaryDrawerItem() .withName("Color") .withIcon(GoogleMaterial.Icon.gmd_invert_colors) .withIconTintingEnabled(true) .withIdentifier(COLOR_FRAGMENT), new PrimaryDrawerItem() .withName("Address") .withIcon(GoogleMaterial.Icon.gmd_home) .withIconTintingEnabled(true) .withIdentifier(ADDRESS_FRAGMENT) ) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(AdapterView adapterView, View view, int i, long l, IDrawerItem iDrawerItem) { if (iDrawerItem != null) { showFragment(iDrawerItem.getIdentifier()); } return false; } }) .withSelectedItem(0) .withSavedInstance(savedInstanceState) .build(); } @Override public void onBackPressed() { if(drawer != null && drawer.isDrawerOpen()) { drawer.closeDrawer(); } else { super.onBackPressed(); } } private void showFragment(int flag) { switch (flag) { case LOREM_FRAGMENT: replace(LoremFragment.newInstance()); break; case NAME_FRAGMENT: replace(NameFragment.newInstance()); break; case NUMBER_FRAGMENT: replace(NumberFragment.newInstance()); break; case PHONE_FRAGMENT: replace(PhoneFragment.newInstance()); break; case INTERNET_FRAGMENT: replace(InternetFragment.newInstance()); break; case URL_FRAGMENT: replace(UrlFragment.newInstance()); break; case PROFILE_FRAGMENT: replace(new ProfileFragment()); break; case RANDOM_WIDGETS_FRAGMENT: replace(new WidgetsFragment()); break; case COLOR_FRAGMENT: replace(ColorFragment.newInstance()); break; case ADDRESS_FRAGMENT: replace(AddressFragment.newInstance()); break; case TARGET_VIEWS_FRAGMENT: replace(new TargetViewsFragment()); break; } } private void replace(Fragment fragment) { if(scrollView == null) { scrollView = (ScrollView) findViewById(R.id.container); } scrollView.fullScroll(ScrollView.FOCUS_UP); getSupportFragmentManager().beginTransaction() .replace(R.id.container, fragment) .commit(); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/AddressFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.TextView; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.AddressPresenter; import io.kimo.faker.mvp.view.AddressView; public class AddressFragment extends BaseView implements AddressView { private AddressPresenter presenter; private View mainView, loadingView; private TextView city, street, secondaryAddress, zipcode, timezone, cityPrefix, citySuffix, state, stateAbbrv, country, countryAbbrv, latitude, longitude; public static AddressFragment newInstance() { return new AddressFragment(); } @Override public void updateCityExample(String value) { city.setText(value); } @Override public void updateStreetExample(String value) { street.setText(value); } @Override public void updateSecondaryAddressExample(String value) { secondaryAddress.setText(value); } @Override public void updateZipcodeExample(String value) { zipcode.setText(value); } @Override public void updateTimezoneExample(String value) { timezone.setText(value); } @Override public void updateCityPrefixExample(String value) { cityPrefix.setText(value); } @Override public void updateCitySuffixExample(String value) { citySuffix.setText(value); } @Override public void updateStateExample(String value) { state.setText(value); } @Override public void updateStateAbbrvExample(String value) { stateAbbrv.setText(value); } @Override public void updateCountryExample(String value) { country.setText(value); } @Override public void updateCountryAbbrvExample(String value) { countryAbbrv.setText(value); } @Override public void updateLatitudeExample(String value) { latitude.setText(value); } @Override public void updateLongitudeExample(String value) { longitude.setText(value); } @Override public int getLayoutResource() { return R.layout.fragment_address; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); city = (TextView) mainView.findViewById(R.id.city); street = (TextView) mainView.findViewById(R.id.street); secondaryAddress = (TextView) mainView.findViewById(R.id.secondary_address); zipcode = (TextView) mainView.findViewById(R.id.zipcode); timezone = (TextView) mainView.findViewById(R.id.timezone); cityPrefix = (TextView) mainView.findViewById(R.id.city_prefix); citySuffix = (TextView) mainView.findViewById(R.id.city_suffix); state = (TextView) mainView.findViewById(R.id.state); stateAbbrv = (TextView) mainView.findViewById(R.id.state_abbrv); country = (TextView) mainView.findViewById(R.id.country); countryAbbrv = (TextView) mainView.findViewById(R.id.country_abbrv); latitude = (TextView) mainView.findViewById(R.id.latitude); longitude = (TextView) mainView.findViewById(R.id.longitude); } @Override public void configureGUI() { getActivity().setTitle("Address"); } @Override public void startPresenter() { presenter = new AddressPresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/ColorFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.ColorPresenter; import io.kimo.faker.mvp.view.ColorView; public class ColorFragment extends BaseView implements ColorView { private View mainView, loadingView, random, red, green, blue, monochrome, bright, dark, light; private ColorPresenter presenter; public static ColorFragment newInstance() { return new ColorFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_color; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); random = view.findViewById(R.id.random_color); red = view.findViewById(R.id.red_color); green = view.findViewById(R.id.green_color); blue = view.findViewById(R.id.blue_color); monochrome = view.findViewById(R.id.monochrome_color); bright = view.findViewById(R.id.bright_color); dark = view.findViewById(R.id.dark_color); light = view.findViewById(R.id.light_color); } @Override public void configureGUI() { getActivity().setTitle("Color"); } @Override public void startPresenter() { presenter = new ColorPresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void updateRandomColorExample(int color) { random.setBackgroundColor(color); } @Override public void updateRedColorExample(int color) { red.setBackgroundColor(color); } @Override public void updateGreenColorExample(int color) { green.setBackgroundColor(color); } @Override public void updateBlueColorExample(int color) { blue.setBackgroundColor(color); } @Override public void updateMonochromeColorExample(int color) { monochrome.setBackgroundColor(color); } @Override public void updateBrightColorExample(int color) { bright.setBackgroundColor(color); } @Override public void updateLightColorExample(int color) { light.setBackgroundColor(color); } @Override public void updateDarkColorExample(int color) { dark.setBackgroundColor(color); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/InternetFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.TextView; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.InternetPresenter; import io.kimo.faker.mvp.view.InternetView; public class InternetFragment extends BaseView implements InternetView { private View mainView, loadingView; private TextView email, url, domain, domainSuffix; private InternetPresenter presenter; public static InternetFragment newInstance() { return new InternetFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_internet; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); email = (TextView) view.findViewById(R.id.email); url = (TextView) view.findViewById(R.id.url); domain = (TextView) view.findViewById(R.id.domain); domainSuffix = (TextView) view.findViewById(R.id.domain_suffix); } @Override public void configureGUI() { getActivity().setTitle("Internet"); } @Override public void startPresenter() { presenter = new InternetPresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void updateEmailExample(String value) { email.setText(value); } @Override public void updateURLExample(String value) { url.setText(value); } @Override public void updateDomainExample(String value) { domain.setText(value); } @Override public void updateDomainSuffixExample(String value) { domainSuffix.setText(value); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/LoremFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.TextView; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.LoremPresenter; import io.kimo.faker.mvp.view.LoremView; public class LoremFragment extends BaseView implements LoremView { private View mainView, loadingView; private TextView character, characters, word, words, sentence, sentences, paragraph, paragraphs; private LoremPresenter presenter; public static LoremFragment newInstance() { return new LoremFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_lorem; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); character = (TextView) view.findViewById(R.id.lorem_character); characters = (TextView) view.findViewById(R.id.lorem_characters); word = (TextView) view.findViewById(R.id.lorem_word); words = (TextView) view.findViewById(R.id.lorem_words); sentence = (TextView) view.findViewById(R.id.lorem_sentence); sentences = (TextView) view.findViewById(R.id.lorem_sentences); paragraph = (TextView) view.findViewById(R.id.lorem_paragraph); paragraphs = (TextView) view.findViewById(R.id.lorem_paragraphs); } @Override public void configureGUI() { getActivity().setTitle("Lorem"); } @Override public void startPresenter() { presenter = new LoremPresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void updateCharacterExample(String value) { character.setText(value); } @Override public void updateCharactersExample(String value) { characters.setText(value); } @Override public void updateWordExample(String value) { word.setText(value); } @Override public void updateWordsExample(String value) { words.setText(value); } @Override public void updateSentenceExample(String value) { sentence.setText(value); } @Override public void updateSentencesExample(String value) { sentences.setText(value); } @Override public void updateParagraphExample(String value) { paragraph.setText(value); } @Override public void updateParagraphsExample(String value) { paragraphs.setText(value); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/NameFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.TextView; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.NamePresenter; import io.kimo.faker.mvp.view.NameView; public class NameFragment extends BaseView implements NameView { private View mainView, loadingView; private TextView completeName, fullName, firstName, lastName, prefix, suffix, title; private NamePresenter presenter; public static NameFragment newInstance() { return new NameFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_name; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); completeName = (TextView) view.findViewById(R.id.complete_name); fullName = (TextView) view.findViewById(R.id.full_name); firstName = (TextView) view.findViewById(R.id.first_name); lastName = (TextView) view.findViewById(R.id.last_name); prefix = (TextView) view.findViewById(R.id.prefix); suffix = (TextView) view.findViewById(R.id.suffix); title = (TextView) view.findViewById(R.id.title); } @Override public void configureGUI() { getActivity().setTitle("Name"); } @Override public void startPresenter() { presenter = new NamePresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } @Override public void updateCompleteNameExample(String value) { completeName.setText(value); } @Override public void updateFullNameExample(String value) { fullName.setText(value); } @Override public void updateFirstNameExample(String value) { firstName.setText(value); } @Override public void updateLastNameExample(String value) { lastName.setText(value); } @Override public void updatePrefixExample(String value) { prefix.setText(value); } @Override public void updateSuffixExample(String value) { suffix.setText(value); } @Override public void updateTitleExample(String value) { title.setText(value); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/NumberFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.TextView; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.NumberPresenter; import io.kimo.faker.mvp.view.NumberView; public class NumberFragment extends BaseView implements NumberView { private View mainView, loadingView; private TextView digit, positiveDigit, negativeDigit, numbers, positiveNumbers, negativeNumbers; private NumberPresenter presenter; public static NumberFragment newInstance() { return new NumberFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_number; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); digit = (TextView) view.findViewById(R.id.digit); positiveDigit = (TextView) view.findViewById(R.id.positive_digit); negativeDigit = (TextView) view.findViewById(R.id.negative_digit); numbers = (TextView) view.findViewById(R.id.number); positiveNumbers = (TextView) view.findViewById(R.id.positive_number); negativeNumbers = (TextView) view.findViewById(R.id.negative_number); } @Override public void configureGUI() { getActivity().setTitle("Numbers"); } @Override public void startPresenter() { presenter = new NumberPresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } @Override public void updateDigit(int value) { digit.setText(String.valueOf(value)); } @Override public void updatePositiveDigit(int value) { positiveDigit.setText(String.valueOf(value)); } @Override public void updateNegativeDigit(int value) { negativeDigit.setText(String.valueOf(value)); } @Override public void updateNumbers(int value) { numbers.setText(String.valueOf(value)); } @Override public void updatePositiveNumbers(int value) { positiveNumbers.setText(String.valueOf(value)); } @Override public void updateNegativeNumbers(int value) { negativeNumbers.setText(String.valueOf(value)); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/PhoneFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.TextView; import android.widget.Toast; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.PhonePresenter; import io.kimo.faker.mvp.view.PhoneView; public class PhoneFragment extends BaseView implements PhoneView { private View mainView, loadingView; private TextView areaCode, countryCode; private PhonePresenter presenter; public static PhoneFragment newInstance() { return new PhoneFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_phone; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); areaCode = (TextView) view.findViewById(R.id.area_code_phone); countryCode = (TextView) view.findViewById(R.id.country_code_phone); } @Override public void configureGUI() { getActivity().setTitle("Phone"); } @Override public void startPresenter() { presenter = new PhonePresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void updatePhoneWithAreaCodeExample(String value) { areaCode.setText(value); } @Override public void updatePhoneWithCountryCodeExample(String value) { countryCode.setText(value); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/ProfileFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.squareup.picasso.Picasso; import io.kimo.faker.R; import io.kimo.lib.faker.Faker; public class ProfileFragment extends Fragment { private ImageView image; private TextView name, title, website, email, phone; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_profile, container, false); image = (ImageView) view.findViewById(R.id.image); name = (TextView) view.findViewById(R.id.name); title = (TextView) view.findViewById(R.id.title); website = (TextView) view.findViewById(R.id.website); email = (TextView) view.findViewById(R.id.email); phone = (TextView) view.findViewById(R.id.phone); return view; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Picasso.with(getActivity()) .load(Faker.with(getActivity()).Url.avatar()) .placeholder(R.drawable.drawer_background) .error(R.drawable.drawer_background) .into(image); name.setText(Faker.with(getActivity()).Name.fullName()); title.setText(Faker.with(getActivity()).Name.title()); website.setText(Faker.with(getActivity()).Internet.url()); email.setText(Faker.with(getActivity()).Internet.email()); phone.setText(Faker.with(getActivity()).Phone.phoneWithAreaCode()); getActivity().setTitle("\"Specific\" Random Data"); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/TargetViewsFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import io.kimo.faker.R; import io.kimo.lib.faker.Faker; public class TargetViewsFragment extends Fragment { View rootView; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_target_views, container, false); return rootView; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getActivity().setTitle("Target Views"); Faker.with(getActivity()) .targetViews(R.id.text, R.id.image, R.id.button) .fill(rootView); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/UrlFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import com.squareup.picasso.MemoryPolicy; import com.squareup.picasso.Picasso; import io.kimo.faker.R; import io.kimo.faker.mvp.BaseView; import io.kimo.faker.mvp.presenter.UrlPresenter; import io.kimo.faker.mvp.view.UrlView; public class UrlFragment extends BaseView implements UrlView { private View mainView, loadingView; private TextView imageUrl, avatarUrl; private ImageView image, avatar; private UrlPresenter presenter; public static UrlFragment newInstance() { return new UrlFragment(); } @Override public int getLayoutResource() { return R.layout.fragment_url; } @Override public void mapGUI(View view) { mainView = view.findViewById(R.id.main_container); loadingView = view.findViewById(R.id.view_loading); imageUrl = (TextView) view.findViewById(R.id.image_url); image = (ImageView) view.findViewById(R.id.image); avatarUrl = (TextView) view.findViewById(R.id.avatar_url); avatar = (ImageView) view.findViewById(R.id.avatar); } @Override public void configureGUI() { getActivity().setTitle("Url"); } @Override public void startPresenter() { presenter = new UrlPresenter(this, getActivity()); presenter.createView(); } @Override public void stopPresenter() { presenter.destroyView(); } @Override public void updateImageUrlExample(String value) { Picasso.with(getActivity()) .load(value) .memoryPolicy(MemoryPolicy.NO_CACHE) .placeholder(R.drawable.drawer_background) .error(R.drawable.drawer_background) .into(image); imageUrl.setText(value); } @Override public void updateAvatarUrlExample(String value) { Picasso.with(getActivity()) .load(value) .memoryPolicy(MemoryPolicy.NO_CACHE) .placeholder(R.drawable.drawer_background) .error(R.drawable.drawer_background) .into(avatar); avatarUrl.setText(value); } @Override public void showFeedback(String msg) { Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT).show(); } @Override public void showView() { mainView.setVisibility(View.VISIBLE); } @Override public void hideView() { mainView.setVisibility(View.GONE); } @Override public void showLoading() { loadingView.setVisibility(View.VISIBLE); } @Override public void hideLoading() { loadingView.setVisibility(View.GONE); } } ================================================ FILE: app/src/main/java/io/kimo/faker/ui/fragment/WidgetsFragment.java ================================================ package io.kimo.faker.ui.fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import io.kimo.faker.R; import io.kimo.lib.faker.Faker; public class WidgetsFragment extends Fragment { private View rootView; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_widgets, container, false); return rootView; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getActivity().setTitle("Random Data"); Faker.with(getActivity()).fill(rootView); } } ================================================ FILE: app/src/main/res/layout/activity_with_toolbar.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_address.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_color.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_internet.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_lorem.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_name.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_number.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_phone.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_profile.xml ================================================ ================================================ FILE: app/src/main/res/layout/fragment_target_views.xml ================================================