Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/HmsDemo.jks
Binary file not shown.
11 changes: 11 additions & 0 deletions app/agconnect-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"client":{
"cp_id":"xxxxxx",
"product_id":"xxxxxx",
"client_id":"xxxxxx",
"client_secret":"xxxxxx",
"app_id":"xxxxxx",
"package_name":"com.jaychang.demo.sa"
},
"configuration_version":"1.0"
}
32 changes: 31 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.huawei.agconnect'


buildscript {
repositories {
Expand All @@ -19,14 +21,38 @@ android {
minSdkVersion deps.build.minSdkVersion
targetSdkVersion deps.build.targetSdkVersion
versionCode 1
multiDexEnabled true
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

signingConfigs {
release {
storeFile file('HmsDemo.jks')
keyAlias 'HmsDemo'
keyPassword 'xxxxxx'
storePassword 'xxxxxx'
v1SigningEnabled true
v2SigningEnabled true
}
}

buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.release
debuggable true
}
}

lintOptions {
abortOnError false
}
Expand All @@ -51,4 +77,8 @@ dependencies {
implementation project(':library-google')
implementation project(':library-instagram')
implementation project(':library-twitter')
implementation project(':library-huawei')
implementation 'com.huawei.agconnect:agconnect-core:1.0.0.300'

implementation 'com.android.support:multidex:1.0.1'
}
18 changes: 18 additions & 0 deletions app/src/main/java/com/jaychang/demo/sa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import com.jaychang.sa.SocialUser
import com.jaychang.sa.facebook.SimpleAuth
import java.util.*


class MainActivity : AppCompatActivity() {

companion object {
const val FACEBOOK = "FACEBOOK"
const val HUAWEI = "HUAWEI"
const val GOOGLE = "GOOGLE"
const val TWITTER = "TWITTER"
const val INSTAGRAM = "INSTAGRAM"
Expand Down Expand Up @@ -41,6 +43,22 @@ class MainActivity : AppCompatActivity() {
})
}

fun connectHuawei(view: View) {
com.jaychang.sa.huawei.SimpleAuth.connectHuawei(object : AuthCallback {
override fun onSuccess(socialUser: SocialUser) {
ProfileActivity.start(this@MainActivity, HUAWEI, socialUser)
}

override fun onError(error: Throwable) {
toast(error.message ?: "")
}

override fun onCancel() {
toast("Canceled")
}
})
}

fun connectGoogle(view: View) {
val scopes = Arrays.asList(
"https://www.googleapis.com/auth/youtube",
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/jaychang/demo/sa/ProfileActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ProfileActivity : AppCompatActivity() {

fun disconnect(view: View) {
when (type) {
MainActivity.HUAWEI -> com.jaychang.sa.huawei.SimpleAuth.disconnectHuawei()
MainActivity.FACEBOOK -> SimpleAuth.disconnectFacebook()
MainActivity.GOOGLE -> com.jaychang.sa.google.SimpleAuth.disconnectGoogle()
MainActivity.TWITTER -> com.jaychang.sa.twitter.SimpleAuth.disconnectTwitter()
Expand All @@ -49,6 +50,7 @@ class ProfileActivity : AppCompatActivity() {

fun revoke(view: View) {
when (type) {
MainActivity.HUAWEI -> com.jaychang.sa.huawei.SimpleAuth.revokeHuawei()
MainActivity.FACEBOOK -> SimpleAuth.revokeFacebook()
MainActivity.GOOGLE -> com.jaychang.sa.google.SimpleAuth.revokeGoogle()
MainActivity.TWITTER -> {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
android:background="#555"
android:orientation="vertical">

<Button
android:id="@+id/connectHwButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="30dp"
android:background="#3b5998"
android:text="@string/connect_hw"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:onClick="connectHuawei"
android:textSize="18sp" />

<Button
android:id="@+id/connectFbButton"
android:layout_width="match_parent"
Expand Down Expand Up @@ -58,4 +72,10 @@
android:textSize="18sp"
android:textColor="@android:color/white" />

<FrameLayout
android:id="@+id/framelog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"></FrameLayout>

</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<resources>
<string name="app_name">SimpleAuth</string>
<string name="connect_hw">connect Huawei</string>
<string name="connect_fb">connect Facebook</string>
<string name="connect_google">connect Google</string>
<string name="connect_twitter">connect Twitter</string>
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ buildscript {
apply from: 'gradle/dependencies.gradle'

repositories {
maven { url 'http://developer.huawei.com/repo/' }
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.huawei.agconnect:agcp:1.2.0.300'
classpath deps.build.gradlePlugins.android
classpath deps.build.gradlePlugins.bintray
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -18,6 +20,7 @@ buildscript {

allprojects {
repositories {
maven { url 'http://developer.huawei.com/repo/' }
mavenCentral()
jcenter()
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public class AuthDataHolder {
private static final AuthDataHolder instance = new AuthDataHolder();

public AuthData huaweiAuthData;
public AuthData facebookAuthData;
public AuthData googleAuthData;
public AuthData twitterAuthData;
Expand Down
68 changes: 68 additions & 0 deletions library-huawei/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Created by .ignore support plugin (hsz.mobi)
### Android template
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches

# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

Loading