Code clean up, removed nasty code, 2 classes that we won't need for now, Logout button added, Polish translation added
This commit is contained in:
parent
c97f892eab
commit
56b472887c
@ -25,7 +25,7 @@
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -294,7 +294,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
||||
private interface ProfileQuery {
|
||||
String[] PROJECTION = {
|
||||
ContactsContract.CommonDataKinds.Email.ADDRESS,
|
||||
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
|
||||
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
|
||||
};
|
||||
|
||||
int ADDRESS = 0;
|
||||
@ -338,49 +338,10 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e("Login error", "nie udalo sie kurde...");
|
||||
Log.e("Login error", "Something went wrong while logging in...");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//To jest async i nie da sie zwrocic :(
|
||||
// Call<JwtToken> call = service.fakeValidate(user);
|
||||
//
|
||||
// call.enqueue(new Callback<JwtToken>() {
|
||||
// @Override
|
||||
// public void onResponse(Call<JwtToken> call, Response<JwtToken> response) {
|
||||
// Log.e("jwt", response.body().getToken());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Call<JwtToken> call, Throwable t) {
|
||||
// Toast.makeText(LoginActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
|
||||
// return false;
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
|
||||
// TODO: attempt authentication against a network service.
|
||||
|
||||
// try {
|
||||
// // Simulate network access.
|
||||
// Thread.sleep(2000);
|
||||
// } catch (InterruptedException e) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// for (String credential : DUMMY_CREDENTIALS) {
|
||||
// String[] pieces = credential.split(":");
|
||||
// if (pieces[0].equals(mEmail)) {
|
||||
// // Account exists, return true if the password matches.
|
||||
// return pieces[1].equals(mPassword);
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO: register the new account here.
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -390,17 +351,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
||||
showProgress(false);
|
||||
|
||||
if (success) {
|
||||
|
||||
// TODO: Ustawiam localstora kluczyk jakis
|
||||
SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sharedPref.edit();
|
||||
editor.putString("test", "jakieś gówno");
|
||||
editor.commit();
|
||||
Log.e("okurwa", "eealslasla");
|
||||
|
||||
// TODO: Ma zwracac 666 i cos jeszcze, do tego wpisywac jwt to shared prefs... kurwa
|
||||
Intent data = new Intent();
|
||||
String txt = "siema eee";
|
||||
String txt = "test text to Startup compo";
|
||||
data.setData(Uri.parse(txt));
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
|
@ -1,10 +1,14 @@
|
||||
package com.uam.wmi.findmytutor.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
@ -37,15 +41,28 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||
setContentView(R.layout.activity_main);
|
||||
final FloatingActionButton button = findViewById(R.id.logoutButton);
|
||||
button.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
SharedPreferences preferences =getSharedPreferences("fmtPrefs",Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.clear().commit();
|
||||
|
||||
Intent i = getBaseContext().getPackageManager()
|
||||
.getLaunchIntentForPackage( getBaseContext().getPackageName() );
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
|
||||
final String authToken = sharedPref.getString("authToken",null);
|
||||
|
||||
Coordinates service = RetrofitClientInstance.createService(Coordinates.class,authToken);
|
||||
@ -85,11 +102,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public abstract class NetworkConnectionInterceptor implements Interceptor {
|
||||
|
||||
public abstract boolean isInternetAvailable();
|
||||
|
||||
public abstract void onInternetUnavailable();
|
||||
|
||||
public abstract void onCacheUnavailable();
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
if (!isInternetAvailable()) {
|
||||
onInternetUnavailable();
|
||||
request = request.newBuilder().header("Cache-Control",
|
||||
"public, only-if-cached, max-stale=" + 60 * 60 * 24).build();
|
||||
Response response = chain.proceed(request);
|
||||
if (response.cacheResponse() == null) {
|
||||
onCacheUnavailable();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
return chain.proceed(request);
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package com.uam.wmi.findmytutor.service;
|
||||
|
||||
public interface Session {
|
||||
}
|
@ -17,12 +17,13 @@
|
||||
<include layout="@layout/content_main" />
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fab"
|
||||
android:id="@+id/logoutButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
app:backgroundTint="@android:color/holo_red_dark"
|
||||
app:srcCompat="@android:drawable/ic_lock_power_off" />
|
||||
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
|
10
app/src/main/res/values-pl/strings.xml
Normal file
10
app/src/main/res/values-pl/strings.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="title_activity_login">Zaloguj</string>
|
||||
<string name="prompt_password">Hasło (opcjonalne)</string>
|
||||
<string name="action_sign_in_short">Zaloguj</string>
|
||||
<string name="error_incorrect_password">Nieprawidłowe hasło</string>
|
||||
<string name="error_invalid_password">Hasło jest zbyt krótkie</string>
|
||||
<string name="error_invalid_email">Nieprawidłowy mail</string>
|
||||
<string name="error_field_required">To pole jest wymagane</string>
|
||||
</resources>
|
@ -1,11 +1,11 @@
|
||||
<resources>
|
||||
<string name="app_name">FindMyTutor</string>
|
||||
<string name="app_name" translatable="false">FindMyTutor</string>
|
||||
<string name="title_activity_login">Sign in</string>
|
||||
<string name="title_activity_startup">StartUp Activity</string>
|
||||
<string name="title_activity_startup" translatable="false">StartUp Activity</string>
|
||||
|
||||
|
||||
<!-- Strings related to login -->
|
||||
<string name="prompt_email">Email</string>
|
||||
<string name="prompt_email" translatable="false">Email</string>
|
||||
<string name="prompt_password">Password (optional)</string>
|
||||
<string name="action_sign_in">Sign in or register</string>
|
||||
<string name="action_sign_in_short">Sign in</string>
|
||||
@ -16,6 +16,6 @@
|
||||
<string name="permission_rationale">"Contacts permissions are needed for providing email
|
||||
completions."
|
||||
</string>
|
||||
<string name="title_activity_main">MainActivity</string>
|
||||
<string name="access_token">pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew</string>
|
||||
<string name="title_activity_main" translatable="false">MainActivity</string>
|
||||
<string name="access_token" translatable="false">pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user