Skip to content

Commit

Permalink
changing the url build
Browse files Browse the repository at this point in the history
  • Loading branch information
FdevTech committed Apr 1, 2021
1 parent 621d718 commit 58bd0c8
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 11 deletions.
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import javax.crypto.SecretKey

plugins {
id 'com.android.application'
id 'kotlin-android'
Expand All @@ -21,9 +23,16 @@ android {
}

buildTypes {
debug{
buildConfigField 'String', "clientID", Access_Key
buildConfigField 'String', 'clientSecret', Secret_key
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

buildConfigField 'String', "clientID", Access_Key
buildConfigField 'String', 'clientSecret', Secret_key
}
}
compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.net.Uri;
import android.util.Log;

import com.example.p5i.onlinegallery.BuildConfig;
import com.example.p5i.onlinegallery.authenticationModule.authorizationData.AutorizationInterface;
import com.example.p5i.onlinegallery.authenticationModule.authorizationData.AutorizationResponsePJO;
import com.example.p5i.onlinegallery.authenticationModule.authorizationData.LoginStateModel;
Expand All @@ -19,25 +20,37 @@
public class UnsplashWebServiceLoginModel
{
private static final String TAG = "LoginModel";

private Retrofit retrofit;
private AutorizationInterface mAutorizationInterface;
private MutableLiveData<Boolean> isLogedIn;
private LoginStateModel mLoginStateModel;

private String clientID="U4e3aiPSmYENZTwqMYUMv1P2XftujdL6byd9e_jM_UI";
private String clientSecret="TVnudFDwuYEJuL0GvB8qcCAR9Vqsr14GcMYVwa8B0OM";
private String clientID= BuildConfig.clientID;
private String clientSecret=BuildConfig.clientSecret;
private String redirect_uri="curta://callback";
private String scope="public read_user write_user read_photos write_photos write_likes write_followers read_collections write_collections";


private Uri.Builder builder=new Uri.Builder();

String URL;

/*private String url="https://unsplash.com/oauth/authorize?client_id="+clientID+"&redirect_uri="+redirect_uri +
"&response_type=code&scope=public read_user write_user read_photos write_photos write_likes write_followers read_collections write_collections";*/

private String url="https://unsplash.com/oauth/authorize?" +
"client_id=U4e3aiPSmYENZTwqMYUMv1P2XftujdL6byd9e_jM_UI&" +
"redirect_uri=curta://callback&" +
"response_type=code" +
"&scope=public read_user write_user read_photos write_photos write_likes write_followers read_collections write_collections";
public UnsplashWebServiceLoginModel(Context context)
{
builder.scheme("https")
.authority("unsplash.com")
.appendPath("oauth")
.appendPath("authorize")
.appendQueryParameter("client_id",clientID)
.appendQueryParameter("redirect_uri",redirect_uri)
.appendQueryParameter("response_type","code")
.appendQueryParameter("scope",scope)
.build();
URL=builder.toString();


mLoginStateModel=new LoginStateModel(context);
isLogedIn=new MutableLiveData<>();
isLogedIn.setValue(false);
Expand Down Expand Up @@ -78,6 +91,6 @@ public MutableLiveData<Boolean> getIsLogedIn() {
}

public String getUrl() {
return url;
return URL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.example.p5i.onlinegallery.photosModule.repository

import android.util.Log
import android.widget.Toast
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.example.p5i.onlinegallery.collectionsModule.datlayer.network.CollectionAPI
import com.example.p5i.onlinegallery.databse.UnsplashDatabase
Expand Down Expand Up @@ -32,6 +34,12 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
it.asUserLikedPhotoDomainModel()
}

private var _eroorCode=MutableLiveData<Int>()
val eroorCode:LiveData<Int>
get() {
return _eroorCode
}



suspend fun like_unlikePhoto(photo_id:String)
Expand Down Expand Up @@ -87,6 +95,7 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
val xtotal= response.headers().get("X-Total")
Log.d(TAG, "referchPhotosToTest: xtotal: $xtotal")
val pages:Int?=(xtotal?.toInt()?.div(30))?.toInt()
_eroorCode.postValue(response.code())
if(photosList!=null)
{
try {
Expand Down Expand Up @@ -115,6 +124,7 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
val response=Photos.PhotosAPI.photos.getPhotoFromTopic(credentials,topicName = topicName)
var photosList= response.body()
val xtotal= Photos.PhotosAPI.photos.getPhotos(credentials).headers().get("X-Total")
_eroorCode.postValue(response.code())
Log.d(TAG, "retrivePhotoFromTopicsToTest: xtotal: $xtotal")
Log.d(TAG, "retrivePhotoFromTopicsToTest: body ${response.body()?.size}")
Log.d(TAG, "retrivePhotoFromTopicsToTest: response errorBody ${response.errorBody()}")
Expand Down Expand Up @@ -143,6 +153,7 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
var photosList= response.body()
val xtotal= response.headers().get("X-Total")
Log.d(TAG, "retrivePhotoFromCollectionToTest: xtotal: $xtotal")
_eroorCode.postValue(response.code())
val pages:Int?=(xtotal?.toInt()?.div(30))?.toInt()
Log.d(TAG, "retrivePhotoFromCollectionToTest: pages $pages")
Log.d(TAG, "retrivePhotoFromCollectionToTest: code: ${response.code()}")
Expand Down Expand Up @@ -217,6 +228,7 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
Log.d(TAG, "retriveUserPhotosToTest: xtotal: $xtotal")
val pages:Int?=(xtotal?.toInt()?.div(30))?.toInt()
Log.d(TAG, "retriveUserPhotosToTest: pages $pages")
_eroorCode.postValue(response.code())
if(photosList!=null)
{
try {
Expand Down Expand Up @@ -258,10 +270,12 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
val response=Photos.PhotosAPI.photos.getUserLikedPhotos(credentials,username = userName!!)
var photosList= response.body()
val xtotal= response.headers().get("X-Total")
_eroorCode.postValue(response.code())
Log.d(TAG, "retriveUserLikedPhotosToTest: xtotal: $xtotal")
val pages:Int?=(xtotal?.toInt()?.div(30))?.toInt()
Log.d(TAG, "retriveUserLikedPhotosToTest: pages $pages")
Log.d(TAG, "retriveUserLikedPhotosToTest: code ${response.code()}")
_eroorCode.postValue(response.code())
if(photosList!=null)
{
try {
Expand Down Expand Up @@ -301,6 +315,7 @@ class PhotoRepository(private val unsplashDatabase: UnsplashDatabase,private val
unsplashDatabase.photosDao.insertLikedByUser(photoid,!photolikedornot)
unsplashDatabase.photosDao.addOrRemoveLiked(photoid,numberOflikes)
}
_eroorCode.postValue(responseRequest.code())
}catch (e:Exception)
{
Log.d(TAG, "likeDesLikePhoto: ${e.message}")
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/anim/enter_from.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
/>
</set>
9 changes: 9 additions & 0 deletions app/src/main/res/anim/exit_to.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
android:duration="500">
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
/>
</set>
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.code.style=official
Access_Key ="U4e3aiPSmYENZTwqMYUMv1P2XftujdL6byd9e_jM_UI"
Secret_key="TVnudFDwuYEJuL0GvB8qcCAR9Vqsr14GcMYVwa8B0OM"

0 comments on commit 58bd0c8

Please sign in to comment.