Skip to content

Commit 5ca0141

Browse files
author
Kylian Balan
committed
Adding OAuth2 authorization and adding repo initial sources
0 parents  commit 5ca0141

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+938
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle/
3+
/local.properties
4+
.idea/
5+
.DS_Store
6+
/build
7+
/captures
8+
.externalNativeBuild
9+
.cxx

app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "30.0.2"
8+
9+
defaultConfig {
10+
applicationId "com.epitech.epicture"
11+
minSdkVersion 28
12+
targetSdkVersion 28
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
26+
buildFeatures {
27+
dataBinding true
28+
}
29+
}
30+
31+
dependencies {
32+
implementation fileTree(dir: "libs", include: ["*.jar"])
33+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
34+
implementation 'androidx.core:core-ktx:1.3.2'
35+
implementation 'androidx.appcompat:appcompat:1.2.0'
36+
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
37+
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
38+
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
39+
testImplementation 'junit:junit:4.12'
40+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
41+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
42+
43+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.epitech.epicture
2+
3+
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import androidx.test.platform.app.InstrumentationRegistry
5+
import org.junit.Assert.assertEquals
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
/**
10+
* Instrumented test, which will execute on an Android device.
11+
*
12+
* See [testing documentation](http://d.android.com/tools/testing).
13+
*/
14+
@RunWith(AndroidJUnit4::class)
15+
class ExampleInstrumentedTest {
16+
@Test
17+
fun useAppContext() {
18+
// Context of the app under test.
19+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20+
assertEquals("com.epitech.epicture", appContext.packageName)
21+
}
22+
}

app/src/main/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.epitech.epicture">
4+
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name="com.epitech.epicture.MainActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
23+
</manifest>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.epitech.epicture
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.databinding.DataBindingUtil
8+
import androidx.fragment.app.Fragment
9+
import com.epitech.epicture.databinding.FragmentHomeBinding
10+
import com.epitech.epicture.service.AuthService
11+
12+
class HomeFragment : Fragment() {
13+
override fun onCreateView(
14+
inflater: LayoutInflater,
15+
container: ViewGroup?,
16+
savedInstanceState: Bundle?
17+
): View? {
18+
val binding: FragmentHomeBinding =
19+
DataBindingUtil.inflate(inflater, R.layout.fragment_home, container, false)
20+
val welcomeMessage = "Welcome, " + AuthService.getCredentialValueByKey("account_username")
21+
binding.welcomeMessage.text = welcomeMessage
22+
return binding.root
23+
}
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.epitech.epicture
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.databinding.DataBindingUtil
8+
import androidx.fragment.app.Fragment
9+
import androidx.navigation.findNavController
10+
import com.epitech.epicture.databinding.FragmentLoginBinding
11+
12+
class LoginFragment : Fragment() {
13+
override fun onCreateView(
14+
inflater: LayoutInflater,
15+
container: ViewGroup?,
16+
savedInstanceState: Bundle?
17+
): View? {
18+
val binding: FragmentLoginBinding = DataBindingUtil.inflate(
19+
inflater, R.layout.fragment_login, container, false
20+
)
21+
binding.loginButton.setOnClickListener {
22+
view?.findNavController()?.navigate(R.id.action_homeFragment_to_loginWebviewFragment)
23+
}
24+
return binding.root
25+
}
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.epitech.epicture
2+
3+
import android.os.Bundle
4+
import android.view.LayoutInflater
5+
import android.view.View
6+
import android.view.ViewGroup
7+
import androidx.databinding.DataBindingUtil
8+
import androidx.fragment.app.Fragment
9+
import com.epitech.epicture.config.Config.Companion.CLIENT_ID
10+
import com.epitech.epicture.databinding.FragmentLoginWebviewBinding
11+
12+
class LoginWebviewFragment : Fragment() {
13+
override fun onCreateView(
14+
inflater: LayoutInflater,
15+
container: ViewGroup?,
16+
savedInstanceState: Bundle?
17+
): View? {
18+
val binding: FragmentLoginWebviewBinding = DataBindingUtil.inflate(
19+
inflater, R.layout.fragment_login_webview, container, false
20+
)
21+
binding.loginWebview.webViewClient = MyWebViewClient()
22+
binding.loginWebview.loadUrl("https://api.imgur.com/oauth2/authorize?client_id=" + CLIENT_ID + "&response_type=token")
23+
return binding.root
24+
}
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.epitech.epicture
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import androidx.databinding.DataBindingUtil
6+
import com.epitech.epicture.databinding.ActivityMainBinding
7+
8+
class MainActivity : AppCompatActivity() {
9+
private lateinit var binding: ActivityMainBinding
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
14+
}
15+
}

0 commit comments

Comments
 (0)