Fakultas Ilmu Komputer UI

Commit 0c9127c4 authored by moh. afifun naily's avatar moh. afifun naily
Browse files

update backend uri

parent d67d46ef
Pipeline #1390 failed with stages
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<component name="CopyrightManager">
<settings default="" />
</component>
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="Afifun">
<words>
<w>sukses</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/MyUI.iml" filepath="$PROJECT_DIR$/MyUI.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -18,9 +18,9 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="localhost"
android:host="myui-dev.cs.ui.ac.id"
android:scheme="akuncs"
android:path="/"/>
android:path="/backend/token/"/>
</intent-filter>
</activity>
<activity android:name=".activity.HomeActivity"/>
......
......@@ -36,13 +36,15 @@ public class ServiceGenerator extends AsyncTask<Object, Object, AccessToken> {
this.code = code;
}
public static final String API_BASE_URL = "https://akun.cs.ui.ac.id/";
public static final String BACKEND_BASE_URL = "http://10.0.2.2/";
public static final String API_BASE_URL = "https://api.cs.ui.ac.id/";
public static final String AUTH_BASE_URL = "https://akun.cs.ui.ac.id/";
public static final String BACKEND_BASE_URL = "https://myui-dev.cs.ui.ac.id/backend/";
@Override
protected AccessToken doInBackground(Object... objects) {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
AccessToken data = null;
AccessToken accessToken = null;
Retrofit.Builder builder =
new Retrofit.Builder()
.baseUrl(BACKEND_BASE_URL)
......@@ -61,11 +63,11 @@ public class ServiceGenerator extends AsyncTask<Object, Object, AccessToken> {
}
try{
body = call.execute();
accessToken = body.body();
String isSuccess = Integer.toString(body.code());
Log.i("SUCCESS", isSuccess);
Log.i("REASON", body.message());
JSONObject jsonResult = new JSONObject(new Gson().toJson(body.body()));
//JSONObject access_token = jsonResult.getJSONObject("access_token");
JSONObject jsonResult = new JSONObject(new Gson().toJson(accessToken));
Log.i("TOKEN", jsonResult.toString());
}
catch (IOException e){
......@@ -75,15 +77,17 @@ public class ServiceGenerator extends AsyncTask<Object, Object, AccessToken> {
e.printStackTrace();
}
return data;
return accessToken;
}
@Override
protected void onPostExecute(AccessToken accessToken) {
if(!(accessToken == null)){
Intent i = new Intent(context, HomeActivity.class);
context.startActivity(i);
Intent i = new Intent(this.context, HomeActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra("access_token", accessToken.toString());
this.context.startActivity(i);
}
}
......
package id.ac.ui.cs.myui.activity;
import android.content.Intent;
import android.support.annotation.IdRes;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnTabSelectListener;
......@@ -43,6 +45,10 @@ public class HomeActivity extends AppCompatActivity {
transaction.addToBackStack(null);
transaction.commit();
setTitle("MyUI");
Intent i = getIntent();
String accessToken = i.getStringExtra("acess_token");
}else if(tabId == R.id.tab_jadwal) {
//Use JadwalFragment
JadwalFragment jadwalFragment = new JadwalFragment();
......
......@@ -12,6 +12,12 @@ import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
import android.widget.Toast;
import com.google.gson.Gson;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
......@@ -19,7 +25,12 @@ import id.ac.ui.cs.myui.AccessToken;
import id.ac.ui.cs.myui.LoginService;
import id.ac.ui.cs.myui.R;
import id.ac.ui.cs.myui.ServiceGenerator;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.http.Field;
/**
......@@ -29,7 +40,8 @@ import retrofit2.http.Field;
public class LoginActivity extends AppCompatActivity {
private final String clientId = "2bfJDNTlHhR9TJO6kQ5OsINqeMpNqFrudWOC8Vg9";
private final String redirectUri = "akuncs://localhost/";
private final String redirectUri = "akuncs://myui-dev.cs.ui.ac.id/";
private final String BACKEND_BASE_URL = "https://myui-dev.cs.ui.ac.id/backend/";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -45,7 +57,7 @@ public class LoginActivity extends AppCompatActivity {
public void onClick(View v){
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse(ServiceGenerator.API_BASE_URL + "" + "oauth/authorize/?response_type=code&client_id=" + clientId + "&state=random_state_string"));
Uri.parse(ServiceGenerator.AUTH_BASE_URL + "" + "oauth/authorize/?response_type=code&client_id=" + clientId + "&state=random_state_string"));
startActivity(intent);
}
});
......@@ -64,6 +76,8 @@ public class LoginActivity extends AppCompatActivity {
if (code != null) {
// get access token
try{
// Do in background
ServiceGenerator serviceGenerator = new ServiceGenerator(getApplicationContext(),code);
serviceGenerator.execute();
}
......
......@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import id.ac.ui.cs.myui.R;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment