├── .gitignore
├── .travis.yml
├── CODE_OF_CONDUCT.md
├── LICENSE
├── PATENTS
├── README.md
├── build.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
├── build.gradle
└── src
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── parse
│ │ │ └── twitter
│ │ │ ├── AsyncCallback.java
│ │ │ ├── OAuth1FlowDialog.java
│ │ │ ├── OAuth1FlowException.java
│ │ │ ├── ParseTwitterUtils.java
│ │ │ ├── Twitter.java
│ │ │ └── TwitterController.java
│ └── res
│ │ └── layout
│ │ └── parse_twitter_dialog_login.xml
│ └── test
│ └── java
│ └── com
│ └── parse
│ └── twitter
│ ├── ParseTwitterUtilsTest.java
│ └── TwitterControllerTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # built application files
2 | *.apk
3 | *.ap_
4 |
5 | # files for the dex VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # generated files
12 | bin/
13 | gen/
14 |
15 | # Local configuration file (sdk path, etc)
16 | local.properties
17 |
18 | # Android Studio
19 | .idea
20 | *.iml
21 | *.ipr
22 | *.iws
23 | classes
24 | gen-external-apklibs
25 |
26 | # Gradle
27 | .gradle
28 | build
29 |
30 | # Other
31 | .metadata
32 | */bin/*
33 | */gen/*
34 | testData
35 | testCache
36 |
37 | # Jacoco
38 | jacoco.exec
39 |
40 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | branches:
2 | only:
3 | - master
4 | - /^v4-\d+\.\d+\.\d+$/ # regex
5 |
6 | language: android
7 |
8 | jdk:
9 | - openjdk8
10 |
11 | before_install:
12 | - pip install --user codecov
13 | - mkdir "$ANDROID_HOME/licenses" || true
14 | - echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > "$ANDROID_HOME/licenses/android-sdk-license"
15 |
16 | script:
17 | - ./gradlew clean testDebugUnitTest jacocoTestReport --info
18 |
19 | after_success:
20 | - ./gradlew coveralls
21 | - codecov
22 |
23 | cache:
24 | directories:
25 | - $HOME/.gradle
26 | - $HOME/.m2/repository
27 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at codeofconduct@parseplatform.org. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD License
2 |
3 | For Parse Twitter Utils for Android software
4 |
5 | Copyright (c) 2015-present, Parse, LLC. All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without modification,
8 | are permitted provided that the following conditions are met:
9 |
10 | * Redistributions of source code must retain the above copyright notice, this
11 | list of conditions and the following disclaimer.
12 |
13 | * Redistributions in binary form must reproduce the above copyright notice,
14 | this list of conditions and the following disclaimer in the documentation
15 | and/or other materials provided with the distribution.
16 |
17 | * Neither the name Parse nor the names of its contributors may be used to
18 | endorse or promote products derived from this software without specific
19 | prior written permission.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 |
32 | -----
33 |
34 | As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.
35 |
--------------------------------------------------------------------------------
/PATENTS:
--------------------------------------------------------------------------------
1 | Additional Grant of Patent Rights Version 2
2 |
3 | "Software" means the Parse Twitter Utils for Android software distributed by Parse, LLC.
4 |
5 | Parse, LLC. ("Parse") hereby grants to each recipient of the Software
6 | ("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
7 | (subject to the termination provision below) license under any Necessary
8 | Claims, to make, have made, use, sell, offer to sell, import, and otherwise
9 | transfer the Software. For avoidance of doubt, no license is granted under
10 | Parse’s rights in any patent claims that are infringed by (i) modifications
11 | to the Software made by you or any third party or (ii) the Software in
12 | combination with any software or other technology.
13 |
14 | The license granted hereunder will terminate, automatically and without notice,
15 | if you (or any of your subsidiaries, corporate affiliates or agents) initiate
16 | directly or indirectly, or take a direct financial interest in, any Patent
17 | Assertion: (i) against Parse or any of its subsidiaries or corporate
18 | affiliates, (ii) against any party if such Patent Assertion arises in whole or
19 | in part from any software, technology, product or service of Parse or any of
20 | its subsidiaries or corporate affiliates, or (iii) against any party relating
21 | to the Software. Notwithstanding the foregoing, if Parse or any of its
22 | subsidiaries or corporate affiliates files a lawsuit alleging patent
23 | infringement against you in the first instance, and you respond by filing a
24 | patent infringement counterclaim in that lawsuit against that party that is
25 | unrelated to the Software, the license granted hereunder will not terminate
26 | under section (i) of this paragraph due to such counterclaim.
27 |
28 | A "Necessary Claim" is a claim of a patent owned by Parse that is
29 | necessarily infringed by the Software standing alone.
30 |
31 | A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
32 | or contributory infringement or inducement to infringe any patent, including a
33 | cross-claim or counterclaim.
34 |
35 | -----
36 |
37 | As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [ARCHIVE] Parse Twitter Utils for Android
2 | ## ParseTwitterUtils has moved to [Parse-SDK-Android](https://github.com/parse-community/Parse-SDK-Android)
3 |
4 | [![Build Status][build-status-svg]][build-status-link]
5 | [![License][license-svg]][license-link]
6 | [](https://jitpack.io/#parse-community/ParseTwitterUtils-Android)
7 | [](https://community.parseplatform.org/c/parse-server)
8 | [](#backers)
9 | [](#sponsors)
10 | 
11 |
12 | A utility library to authenticate `ParseUser`s with Twitter.
13 |
14 | ## Dependency
15 |
16 | Add this in your root `build.gradle` file (**not** your module `build.gradle` file):
17 |
18 | ```gradle
19 | allprojects {
20 | repositories {
21 | ...
22 | maven { url "https://jitpack.io" }
23 | }
24 | }
25 | ```
26 |
27 | Then, add the library to your project `build.gradle`
28 | ```gradle
29 | dependencies {
30 | implementation 'com.github.parse-community:ParseTwitterUtils-Android:latest.version.here'
31 | }
32 | ```
33 |
34 | ## Usage
35 | Extensive docs can be found in the [guide][guide]. The basic steps are:
36 | ```java
37 | // in Application.onCreate(); or somewhere similar
38 | ParseTwitterUtils.initialize("YOUR CONSUMER KEY", "YOUR CONSUMER SECRET");
39 | ```
40 | Then later, when your user taps the login button:
41 | ```java
42 | ParseTwitterUtils.logIn(this, new LogInCallback() {
43 | @Override
44 | public void done(ParseUser user, ParseException err) {
45 | if (user == null) {
46 | Log.d("MyApp", "Uh oh. The user cancelled the Twitter login.");
47 | } else if (user.isNew()) {
48 | Log.d("MyApp", "User signed up and logged in through Twitter!");
49 | } else {
50 | Log.d("MyApp", "User logged in through Twitter!");
51 | }
52 | }
53 | });
54 | ```
55 |
56 | ## How Do I Contribute?
57 | We want to make contributing to this project as easy and transparent as possible. Please refer to the [Contribution Guidelines](https://github.com/parse-community/Parse-SDK-Android/blob/master/CONTRIBUTING.md).
58 |
59 | ## License
60 | Copyright (c) 2015-present, Parse, LLC.
61 | All rights reserved.
62 |
63 | This source code is licensed under the BSD-style license found in the
64 | LICENSE file in the root directory of this source tree. An additional grant
65 | of patent rights can be found in the PATENTS file in the same directory.
66 |
67 | As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.
68 |
69 | [guide]: https://docs.parseplatform.org/android/guide/#twitter-users
70 |
71 | [build-status-svg]: https://travis-ci.org/parse-community/ParseTwitterUtils-Android.svg?branch=master
72 | [build-status-link]: https://travis-ci.org/parse-community/ParseTwitterUtils-Android
73 |
74 | [license-svg]: https://img.shields.io/badge/license-BSD-lightgrey.svg
75 | [license-link]: https://github.com/parse-community/ParseTwitterUtils-Android/blob/master/LICENSE
76 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 | dependencies {
7 | classpath "com.android.tools.build:gradle:3.5.2"
8 | classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.3"
9 | classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
10 | }
11 | }
12 |
13 | plugins {
14 | id "com.github.ben-manes.versions" version "0.27.0"
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | jcenter()
21 | maven { url "https://jitpack.io" }
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/parse-community/ParseTwitterUtils-Android/41ad7e57bdabda8e57827e9beec22a40e38440ce/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin, switch paths to Windows format before running java
129 | if $cygwin ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem http://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.library"
2 |
3 | android {
4 | compileSdkVersion 29
5 |
6 | defaultConfig {
7 | minSdkVersion 14
8 | targetSdkVersion 29
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | }
13 |
14 | dependencies {
15 |
16 | api "androidx.appcompat:appcompat:1.1.0"
17 |
18 | api "oauth.signpost:signpost-core:1.2.1.2"
19 |
20 | api "se.akerfeldt:okhttp-signpost:1.1.0"
21 |
22 | api "com.github.parse-community.Parse-SDK-Android:parse:1.22.1"
23 |
24 | testImplementation "junit:junit:4.12"
25 | testImplementation "org.mockito:mockito-core:1.10.19"
26 | }
27 |
28 | //region Code Coverage
29 |
30 | apply plugin: "jacoco"
31 |
32 | jacoco {
33 | toolVersion "0.7.1.201405082137"
34 | }
35 |
36 | task jacocoTestReport(type: JacocoReport, dependsOn: "testDebugUnitTest") {
37 | group = "Reporting"
38 | description = "Generate Jacoco coverage reports"
39 |
40 | classDirectories = fileTree(
41 | dir: "${buildDir}/intermediates/classes/debug",
42 | excludes: ['**/R.class',
43 | '**/R$*.class',
44 | '**/*$ViewInjector*.*',
45 | '**/BuildConfig.*',
46 | '**/Manifest*.*',
47 | '**/gdata/**',
48 | '**/oauth/**',
49 | '**/signpost/**']
50 | )
51 |
52 | sourceDirectories = files("${buildDir.parent}/src/main/java")
53 | additionalSourceDirs = files([
54 | "${buildDir}/generated/source/buildConfig/debug",
55 | "${buildDir}/generated/source/r/debug"
56 | ])
57 | executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec")
58 |
59 | reports {
60 | xml.enabled = true
61 | html.enabled = true
62 | }
63 | }
64 |
65 | //endregion
66 |
67 | //region Coveralls
68 |
69 | apply plugin: "com.github.kt3k.coveralls"
70 |
71 | coveralls.jacocoReportPath = "${buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"
72 |
73 | //endregion
74 |
75 | apply from: "https://raw.githubusercontent.com/Commit451/gradle-android-javadocs/1.1.0/gradle-android-javadocs.gradle"
76 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/main/java/com/parse/twitter/AsyncCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-present, Parse, LLC.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 | package com.parse.twitter;
10 |
11 | public interface AsyncCallback {
12 | void onSuccess(Object result);
13 |
14 | void onCancel();
15 |
16 | void onFailure(Throwable error);
17 | }
18 |
--------------------------------------------------------------------------------
/library/src/main/java/com/parse/twitter/OAuth1FlowDialog.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-present, Parse, LLC.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 | package com.parse.twitter;
10 |
11 | import android.annotation.SuppressLint;
12 | import android.content.Context;
13 | import android.content.DialogInterface;
14 | import android.content.Intent;
15 | import android.graphics.Bitmap;
16 | import android.net.Uri;
17 | import android.os.Bundle;
18 | import androidx.appcompat.app.AppCompatDialog;
19 | import android.view.View;
20 | import android.view.Window;
21 | import android.webkit.WebView;
22 | import android.webkit.WebViewClient;
23 | import android.widget.ProgressBar;
24 |
25 | /**
26 | * For internal use.
27 | */
28 | class OAuth1FlowDialog extends AppCompatDialog {
29 |
30 | private final String callbackUrl;
31 | private final String requestUrl;
32 | private final String serviceUrlIdentifier;
33 | private final FlowResultHandler handler;
34 |
35 | private WebView webView;
36 | private ProgressBar progress;
37 |
38 | OAuth1FlowDialog(Context context, String requestUrl, String callbackUrl, String serviceUrlIdentifier, FlowResultHandler resultHandler) {
39 | super(context);
40 | this.requestUrl = requestUrl;
41 | this.callbackUrl = callbackUrl;
42 | this.serviceUrlIdentifier = serviceUrlIdentifier;
43 | this.handler = resultHandler;
44 | this.setOnCancelListener(new OnCancelListener() {
45 | @Override
46 | public void onCancel(DialogInterface dialog) {
47 | handler.onCancel();
48 | }
49 | });
50 | }
51 |
52 | @SuppressLint("SetJavaScriptEnabled")
53 | @Override
54 | protected void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | requestWindowFeature(Window.FEATURE_NO_TITLE);
57 | setContentView(R.layout.parse_twitter_dialog_login);
58 | webView = findViewById(R.id.webView);
59 | progress = findViewById(R.id.progress);
60 |
61 | webView.setVerticalScrollBarEnabled(false);
62 | webView.setHorizontalScrollBarEnabled(false);
63 | webView.setWebViewClient(new OAuth1WebViewClient());
64 | webView.getSettings().setJavaScriptEnabled(true);
65 | webView.loadUrl(requestUrl);
66 | }
67 |
68 | public interface FlowResultHandler {
69 | /**
70 | * Called when the user cancels the dialog.
71 | */
72 | void onCancel();
73 |
74 | /**
75 | * Called when the dialog's web view receives an error.
76 | */
77 | void onError(int errorCode, String description, String failingUrl);
78 |
79 | /**
80 | * Called when the dialog portion of the flow is complete.
81 | *
82 | * @param callbackUrl The final URL called back (including any query string appended
83 | * by the server).
84 | */
85 | void onComplete(String callbackUrl);
86 | }
87 |
88 | private class OAuth1WebViewClient extends WebViewClient {
89 | @Override
90 | public boolean shouldOverrideUrlLoading(WebView view, String url) {
91 | if (url.startsWith(callbackUrl)) {
92 | OAuth1FlowDialog.this.dismiss();
93 | handler.onComplete(url);
94 | return true;
95 | } else if (url.contains(serviceUrlIdentifier)) {
96 | return false;
97 | }
98 | // launch non-service URLs in a full browser
99 | getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
100 | return true;
101 | }
102 |
103 | @Override
104 | public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
105 | super.onReceivedError(view, errorCode, description, failingUrl);
106 | OAuth1FlowDialog.this.dismiss();
107 | handler.onError(errorCode, description, failingUrl);
108 | }
109 |
110 | @Override
111 | public void onPageStarted(WebView view, String url, Bitmap favicon) {
112 | super.onPageStarted(view, url, favicon);
113 | progress.setVisibility(View.VISIBLE);
114 | }
115 |
116 | @Override
117 | public void onPageFinished(WebView view, String url) {
118 | super.onPageFinished(view, url);
119 | progress.setVisibility(View.GONE);
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/library/src/main/java/com/parse/twitter/OAuth1FlowException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-present, Parse, LLC.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 | package com.parse.twitter;
10 |
11 | /**
12 | * OAuth Flow exception
13 | */
14 | public class OAuth1FlowException extends Exception {
15 | private static final long serialVersionUID = 4272662026279290823L;
16 | private final int errorCode;
17 | private final String description;
18 | private final String failingUrl;
19 |
20 | public OAuth1FlowException(int errorCode, String description, String failingUrl) {
21 | super(String.format("OAuth Flow Error %d: Url: %s Description: %s", errorCode, failingUrl,
22 | description));
23 | this.errorCode = errorCode;
24 | this.description = description;
25 | this.failingUrl = failingUrl;
26 | }
27 |
28 | public int getErrorCode() {
29 | return errorCode;
30 | }
31 |
32 | public String getDescription() {
33 | return description;
34 | }
35 |
36 | public String getFailingUrl() {
37 | return failingUrl;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/com/parse/twitter/ParseTwitterUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015-present, Parse, LLC.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 | package com.parse.twitter;
10 |
11 | import android.content.Context;
12 |
13 | import com.parse.AuthenticationCallback;
14 | import com.parse.LogInCallback;
15 | import com.parse.ParseException;
16 | import com.parse.ParseUser;
17 | import com.parse.SaveCallback;
18 |
19 | import java.util.Map;
20 | import java.util.concurrent.CancellationException;
21 |
22 | import bolts.AggregateException;
23 | import bolts.Continuation;
24 | import bolts.Task;
25 |
26 | /**
27 | * Provides a set of utilities for using Parse with Twitter.
28 | */
29 | public final class ParseTwitterUtils {
30 | private static final String AUTH_TYPE = "twitter";
31 |
32 | private static final String CALLBACK_URL = "twittersdk://";
33 |
34 | private static final Object lock = new Object();
35 | static boolean isInitialized;
36 | static TwitterController controller;
37 | static ParseUserDelegate userDelegate = new ParseUserDelegateImpl();
38 |
39 | private static TwitterController getTwitterController() {
40 | synchronized (lock) {
41 | if (controller == null) {
42 | controller = new TwitterController();
43 | }
44 | return controller;
45 | }
46 | }
47 |
48 | /**
49 | * Gets the shared {@link Twitter} singleton that Parse is using.
50 | *
51 | * @return {@link Twitter} instance.
52 | */
53 | public static Twitter getTwitter() {
54 | return getTwitterController().getTwitter();
55 | }
56 |
57 | /**
58 | * Initializes Twitter for use with Parse. This method must be invoked prior to calling
59 | * {@link #link(ParseUser, Context, SaveCallback)} and {@link #logIn(Context, LogInCallback)}.
60 | *
61 | * @param consumerKey Your Twitter consumer key.
62 | * @param consumerSecret Your Twitter consumer secret.
63 | */
64 | public static void initialize(String consumerKey, String consumerSecret) {
65 | initialize(consumerKey, consumerSecret, CALLBACK_URL);
66 | }
67 |
68 | /**
69 | * Initializes Twitter for use with Parse. This method must be invoked prior to calling
70 | * {@link #link(ParseUser, Context, SaveCallback)} and {@link #logIn(Context, LogInCallback)}.
71 | *
72 | * @param consumerKey Your Twitter consumer key.
73 | * @param consumerSecret Your Twitter consumer secret.
74 | * @param callbackUrl the callback url
75 | */
76 | public static void initialize(String consumerKey, String consumerSecret, String callbackUrl) {
77 | synchronized (lock) {
78 | if (isInitialized) {
79 | return;
80 | }
81 |
82 | if (controller == null) {
83 | Twitter twitter = new Twitter(consumerKey, consumerSecret, callbackUrl);
84 | controller = new TwitterController(twitter);
85 | } else {
86 | controller.initialize(consumerKey, consumerSecret);
87 | }
88 |
89 | userDelegate.registerAuthenticationCallback(AUTH_TYPE, new AuthenticationCallback() {
90 | @Override
91 | public boolean onRestore(Map authData) {
92 | try {
93 | getTwitterController().setAuthData(authData);
94 | return true;
95 | } catch (Exception e) {
96 | return false;
97 | }
98 | }
99 | });
100 |
101 | isInitialized = true;
102 | }
103 | }
104 |
105 | private static void checkInitialization() {
106 | if (!isInitialized) {
107 | throw new IllegalStateException(
108 | "You must call ParseTwitterUtils.initialize() before using ParseTwitterUtils");
109 | }
110 | }
111 |
112 | /**
113 | * @return {@code true} if the user is linked to a Twitter account.
114 | */
115 | public static boolean isLinked(ParseUser user) {
116 | return user.isLinked(AUTH_TYPE);
117 | }
118 |
119 | /**
120 | * Links a ParseUser to a Twitter account, allowing you to use Twitter for authentication, and
121 | * providing access to Twitter data for the user. A dialog will be shown to the user for Twitter
122 | * authentication.
123 | *
124 | * @param user The user to link to a Twitter account.
125 | * @param context An Android context from which the login dialog can be launched.
126 | * @return A Task that will be resolved when linking is completed.
127 | */
128 | public static Task linkInBackground(Context context, final ParseUser user) {
129 | checkInitialization();
130 | return getTwitterController().authenticateAsync(context).onSuccessTask(new Continuation