Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

Commit

Permalink
update build configuration to ease open source transition, if I do it
Browse files Browse the repository at this point in the history
  • Loading branch information
klinker24 committed Jun 13, 2018
1 parent 2eec144 commit b1f5411
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 53 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ local.properties
**/gen
*~
.DS_Store
secrets.properties
41 changes: 40 additions & 1 deletion app/build.gradle
Expand Up @@ -8,7 +8,7 @@ def props = new Properties()
if (keystoreProperties.exists()) {
props.load(new FileInputStream(keystoreProperties))
} else {
props['keystorefile'] = 'none';
props['keystorefile'] = 'none'
}

android {
Expand Down Expand Up @@ -36,6 +36,45 @@ android {
versionCode System.getenv("BUILD_NUMBER") as Integer ?: Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
multiDexEnabled true

File secretsExists = new File("secrets.properties")
if (secretsExists.exists()) {
def secretsFile = rootProject.file('secrets.properties')
def secrets = new Properties()
secrets.load(new FileInputStream(secretsFile))

buildConfigField "String", "CONSUMER_KEY", secrets['CONSUMER_KEY']
buildConfigField "String", "CONSUMER_SECRET", secrets['CONSUMER_SECRET']
buildConfigField "String", "YOUTUBE_API_KEY", secrets['YOUTUBE_API_KEY']
buildConfigField "String", "TWEETMARKER_KEY",secrets['TWEETMARKER_KEY']
buildConfigField "String", "TWITLONGER_KEY", secrets['TWITLONGER_KEY']
buildConfigField "String", "GIPHY_API_KEY", secrets['GIPHY_KEY']
buildConfigField "String", "ARTICLE_API_KEY", secrets['ARTICLE_KEY']
buildConfigField "String", "MERCURY_API_KEY", secrets['MERCURY_KEY']

buildConfigField "String", "CONSUMER_KEY_OLD_1", secrets['CONSUMER_KEY_OLD_1'] != null ? secrets['CONSUMER_KEY_OLD_1'] : "\"This is optional.\""
buildConfigField "String", "CONSUMER_SECRET_OLD_1", secrets['CONSUMER_SECRET_OLD_1'] != null ? secrets['CONSUMER_SECRET_OLD_1'] : "\"This is optional.\""
buildConfigField "String", "CONSUMER_KEY_OLD_2", secrets['CONSUMER_KEY_OLD_12'] != null ? secrets['CONSUMER_KEY_OLD_2'] : "\"This is optional.\""
buildConfigField "String", "CONSUMER_SECRET_OLD_2", secrets['CONSUMER_SECRET_OLD_2'] != null ? secrets['CONSUMER_SECRET_OLD_2'] : "\"This is optional.\""
buildConfigField "String", "CONSUMER_KEY_OLD_3", secrets['CONSUMER_KEY_OLD_3'] != null ? secrets['CONSUMER_KEY_OLD_3'] : "\"This is optional.\""
buildConfigField "String", "CONSUMER_SECRET_OLD_3", secrets['CONSUMER_SECRET_OLD_3'] != null ? secrets['CONSUMER_SECRET_OLD_3'] : "\"This is optional.\""
} else {
buildConfigField "String", "CONSUMER_KEY", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "CONSUMER_SECRET", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "YOUTUBE_API_KEY", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "TWEETMARKER_KEY", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "TWITLONGER_KEY", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "GIPHY_API_KEY", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "ARTICLE_API_KEY", "\"View Talon's readme to learn about inserting your keys.\""
buildConfigField "String", "MERCURY_API_KEY", "\"View Talon's readme to learn about inserting your keys.\""

buildConfigField "String", "CONSUMER_KEY_OLD_1", "\"This is optional.\""
buildConfigField "String", "CONSUMER_SECRET_OLD_1", "\"This is optional.\""
buildConfigField "String", "CONSUMER_KEY_OLD_2", "\"This is optional.\""
buildConfigField "String", "CONSUMER_SECRET_OLD_2", "\"This is optional.\""
buildConfigField "String", "CONSUMER_KEY_OLD_3", "\"This is optional.\""
buildConfigField "String", "CONSUMER_SECRET_OLD_3", "\"This is optional.\""
}
}

File keystore = new File(props['keystorefile'])
Expand Down
36 changes: 15 additions & 21 deletions app/src/main/java/com/klinker/android/twitter_l/APIKeys.java
Expand Up @@ -77,20 +77,20 @@ public APIKeys(Context c) {

// Key version is stored in the MaterialLogin.KEY_VERSION field.
// Talon Plus
public static String TWITTER_CONSUMER_KEY = "***REMOVED***";
public static String TWITTER_CONSUMER_SECRET = "***REMOVED***";
public static String TWITTER_CONSUMER_KEY = BuildConfig.CONSUMER_KEY_OLD_1;
public static String TWITTER_CONSUMER_SECRET = BuildConfig.CONSUMER_SECRET_OLD_1;

// Talon (Plus)
public static String TWITTER_CONSUMER_KEY_2 = "***REMOVED***";
public static String TWITTER_CONSUMER_SECRET_2 = "***REMOVED***";
public static String TWITTER_CONSUMER_KEY_2 = BuildConfig.CONSUMER_KEY_OLD_2;
public static String TWITTER_CONSUMER_SECRET_2 = BuildConfig.CONSUMER_SECRET_OLD_2;

// Talon - Plus
public static String TWITTER_CONSUMER_KEY_3 = "***REMOVED***";
public static String TWITTER_CONSUMER_SECRET_3 = "***REMOVED***";
public static String TWITTER_CONSUMER_KEY_3 = BuildConfig.CONSUMER_KEY_OLD_3;
public static String TWITTER_CONSUMER_SECRET_3 = BuildConfig.CONSUMER_SECRET_OLD_3;

// Talon Android (June 5th w/ 77,056 downloads)
public static String TWITTER_CONSUMER_KEY_4 = "***REMOVED***";
public static String TWITTER_CONSUMER_SECRET_4 = "***REMOVED***";
public static String TWITTER_CONSUMER_KEY_4 = BuildConfig.CONSUMER_KEY;
public static String TWITTER_CONSUMER_SECRET_4 = BuildConfig.CONSUMER_SECRET;

/**
* For the In-App Youtube Player
Expand All @@ -100,22 +100,16 @@ public APIKeys(Context c) {
* Here is how you can get a key for yourself:
* https://developers.google.com/youtube/android/player/register
*/
public static String YOUTUBE_API_KEY = "***REMOVED***";
public static String YOUTUBE_API_KEY = BuildConfig.YOUTUBE_API_KEY;

/**
* These are third party service API keys for Talon.
*
* If you wish to use these services, You will need to get a key as I will not be sharing mine
* for obvious security reasons.
*
* Tweetmarker is a paid service, so if you want a key, you will have to pay $75 a month for it
* For Twitlonger, you must request access to their API for your app. I do not know if he would grant an Open Source Api key or not.
* TwitPic is dead, but I kept its classes in here so that you can still learn from them. The service no longer is supported.
* If you wish to use these services, You will need to get a key for the ones you want to use.
*/
public static final String TWEETMARKER_API_KEY = "***REMOVED***";
public static final String TWITLONGER_API_KEY = "***REMOVED***";
public static final String TWITPIC_API_KEY = "8cd3757bb6acb94c61e3cbf840c91872";
public static final String GIPHY_API_KEY = "***REMOVED***";
public static final String ARTICLE_API_KEY = "***REMOVED***";
public static final String MERCURY_API_KEY = "***REMOVED***";
public static final String TWEETMARKER_API_KEY = BuildConfig.TWEETMARKER_KEY;
public static final String TWITLONGER_API_KEY = BuildConfig.TWITLONGER_KEY;
public static final String GIPHY_API_KEY = BuildConfig.GIPHY_API_KEY;
public static final String ARTICLE_API_KEY = BuildConfig.ARTICLE_API_KEY;
public static final String MERCURY_API_KEY = BuildConfig.MERCURY_API_KEY;
}
53 changes: 22 additions & 31 deletions readme.md
Expand Up @@ -2,62 +2,53 @@

![Main Drawer](Other/Promo\ Stuff/Graphics/Plus/Final\ Promos/Feature\ graphic\ 4.png)

This is the Material Design version of Talon, my popular Twitter client.
This is the complete version of the Twitter client that I created for Android. It is 100% open source, the only thing that you will have to do plug in is your own API keys.

### Compiling Talon
The code hasn't all aged-well. Most of it was created when I was just learning about coding. It works well though and can probably be considered one of the most popular third party Twitter apps.

Please don't try to compile it as an ANT build. I beg you, just use Android Studio or IntelliJ and compile it with Gradle. It will make your life so much easier and I will not be answering questions about dependencies and compiling for Eclipse. We spent a long time changing all of our projects over to Gradle and I want it to help some people.
### Building Talon

To compile it:

1. Check out the project with a *git clone <clone path here>*
2. You can compile it from the command line by CDing into the folder then *./gradlew assembleDebug*
3. Import it to IntelliJ or Android Studio by going to File -> Import Project... then selecting the *build.gradle* file in the root of the project
Before Talon will work, you will need to generate some API keys, for Twitter. I will not be distributing my keys.

To get your Twitter API key, go through these steps:

1. sign in on their developer site (https://apps.twitter.com/)
2. Click *Create New App* You will have to implement a callback url.
2. Click `Create New App`.
3. Choose a name, description, and website. These are all required and unique to your app, but it makes no difference what you call them. Anything will work here.
4. For the callback URL, you can do anything you like, but to have it work out of the box, use: *http://www.talonforandroid.com*
* If you want a different one (stressing that it really DOES NOT matter..) then change it in the LoginActivity under com.klinker.android.twitter.ui.setup
5. Read and accept their *Rules of the Road*, then *Create your Twitter Application*
4. For the callback URL, you can do anything you like, but to have it work out of the box, use: `http://talonfortwitter.com`
* If you want a different one (stressing that it really DOES NOT matter..) then change it in the `LoginFragment`
5. Read and accept their `Rules of the Road`, then `Create your Twitter Application`
6. After it is created, you can change the icon and add some other info from the settings page.
7. You NEED to go to the *Permissions* page of the app and select the *Read, Write and Access direct messages* option, or else you won't be able to do anything but view your timeline.

Once you get signed up and everything, just copy and paste your API key and API secret into the APIKeys class.

If you get TwitLonger or TweetMarker support, you can paste the keys for that into APIKeys class as well. If you do not get them, then those services WILL NOT work.


### Pull Requests

One of the reasons that I decided to open source this wasn't just because people would be able to learn from it. I also need help. There are somethings that I just don't know how to do any better. I don't have experience or knowledge yet to understand what is going wrong with them or why they randomly fail for some people.

I have done the absolute best I can with this app, but the more minds working on it, the better. Chances are if you are here and actually reading the readme, you have far more experience programming than me anyways and know how things can be improved.
7. You NEED to go to the `Permissions` page of the app and select the `Read, Write and Access direct messages` option, or else you won't be able to do anything but view your timeline.

##### Adding API Keys to the App

### Issues
In the `.gitignore` file, I have ignored `secrets.properties` which should contain your keys. Go ahead, copy the `secrets.properties.sample` to `secrets.properties` and fill in the keys in it.

If you think something could be done better, then tell me. I am not saying that I will agree with you on it or that it will ever be the way you think it should be, but there is no hurt in asking.
This allows me to keep the keys out of source control, but still build the app without any hassle.

There are fields for the Twitter keys, as well as some third party services that Talon utilizes. You do not have to generate keys for the third party services. Those services just will not work.

### Wrap Up
##### Providing a Signing Configuration

There isn't to much more I have to say about this. I have put a ton of time and effort into this project and I truly hope that this helps someone out there. Take the leap, try something you never have before, see what you can learn from me and my mistakes.
For release builds, add your keystore simply as `keystore` to the root of the project, then add a `keystore.properties` file to the root with (no quotation marks around these strings!):

Let me know if you have questions and I will answer them to the best of my ability.
```
KEY_SIGNATURE=xxxx
KEY_ALIAS=xxxx
```

Thanks and have fun with Talon!
## Contributing


Please fork this repository and contribute back using [pull requests](https://github.com/klinker24/Talon-for-Twitter/pulls). Features can be requested using [issues](https://github.com/klinker24/Talon-for-Twitter/issues). All code, comments, and critiques are greatly appreciated.


---

## License

Copyright 2016 Luke Klinker
Copyright 2018 Luke Klinker

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
53 changes: 53 additions & 0 deletions secrets.properties.sample
@@ -0,0 +1,53 @@
#
# Twitter's API Keys
# THESE TWO ARE THE ONLY ONES REQUIRED TO RUN THE APP!
# They are easy to obtain from Twitter
#
# Sign in with your Twitter credentials here:
# https://apps.twitter.com/
#
# Then create a new application.
#
# For steps to creating an application, view the Readme.md
#

CONSUMER_KEY=""
CONSUMER_SECRET=""


#
# For the In-App Youtube Player
# It WILL NOT work if you do not obtain a key for yourself.
# It is easy to get one of these though.
#
# Here is how you can get a key for yourself:
# https://developers.google.com/youtube/android/player/register
#

YOUTUBE_API_KEY=""


#
# These are third party service API keys for Talon.
#
# If you wish to use these services, You will need to get a key for them, on your own.
#

TWEETMARKER_KEY=""
TWITLONGER_KEY=""
MERCURY_KEY=""


#
# The Giphy key is their default beta key. You don't have to change it.
#

GIPHY_KEY="dc6zaTOxFJmzC"


#
# This Article key is to use the readability browser. Feel free to use this key,
# it is granted for the open source version of Talon.
#

ARTICLE_KEY="2643c5064704db3ab62ef5b474e4defc"

0 comments on commit b1f5411

Please sign in to comment.