Android app, which allows to search tweets as user types and scroll them infinitely
Utilizes modern Android libraries
for Dependency Injection, Reactive Programming, Networking, Images Loading, Logging, User Interface, etc.
Code quality is assured by Unit Tests, Static Code Analysis and Continuous Integration.
- Overview
- Screenshot
- Configuration of Twitter API keys and tokens
- Twitter API rate limits
- Building the project
- Tests
- Static Code Analysis
- Code style
- Used libraries
- License
User can search tweets with a given keyword as he or she types or by touching search icon. Moreover, application has so called infinite scroll for tweets. Implementation of the dynamic search is quite simple thanks to RxJava and Reactive Programming principles.
Go to https://apps.twitter.com/ website, register your account and Twitter app. Next, generate your keys and tokens.
When you have them, go to gradle.properties
file in the repository
and add the following contents to this file:
TWITTER_CONSUMER_KEY=your-consumer-key
TWITTER_CONSUMER_SECRET=your-consumer-secret
TWITTER_ACCESS_TOKEN=your-access-token
TWITTER_ACCESS_TOKEN_SECRET=your-access-token-secret
and set your keys and tokens to appropriate variables.
After that, you can build and run the app.
We shouldn't keep tokens and API keys in the Git repository. In order to work efficiently with Git, we can add gradle.properties
file to .gitignore
file in the repository or add the following aliases to our .gitconfig
file:
ignore-local = update-index --assume-unchanged
unignore-local = update-index --no-assume-unchanged
ignored-local = !git ls-files -v | grep "^[[:lower:]]"
Then, we can execute:
$ git ignore-local gradle.properties
After that, we can add our keys and tokens to this file and our secrets won't be commited or pushed.
To undo this operation, we can simply call:
$ git unignore-local gradle.properties
To list all files ingored locally in the Git repository, we can call:
$ git ignored-local
Please remember that Twitter API has its own rate limits, so when user will perform too many requests in a short period of time, further requests may be blocked for a given amount of time. Don't worry - it's not so long. Error code for rate limit is provided in TwitterApiProvider
class and is used by RxJava error handling in MainActivity
class.
We can build project with Gradle Wrapper and the following command:
./gradlew build
Tets are located in app/src/androidTest/java
and can be executed on device or emulator with the following command:
./gradlew connectedCheck
Reports from tests are located in app/build/reports/androidTests/
directory.
Project uses the following tools for static code analysis configured in config/quality.gradle
file:
- Checkstyle
- PMD
- FindBugs
- Android Lint
Reference to this file is added in app/build.gradle
file.
Static Code analysis can be executed with the following command:
./gradlew check
Reports from analysis are generated in app/build/reports/
directory.
Code style used in the project is called SquareAndroid
from Java Code Styles repository by Square available at: https://github.com/square/java-code-styles.
- In application
- In tests
Copyright 2016 Piotr Wittchen
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.