Commit e547bc85 authored by Lucas Braz Cunha's avatar Lucas Braz Cunha

Request bug fixed (token updated to null) & osb access tag refactoring

Signed-off-by: Lucas Braz Cunha's avatarLucas Braz Cunha <lbc16@inf.ufpr.br>
parent cd9b5e99
......@@ -34,6 +34,8 @@ import br.ufpr.c3sl.agendador.agendador.models.UserOutput;
public abstract class Utils {
public static final String APP_NAME = "Agendador";
public static final String DATE_HOUR_FORMAT = "dd/MM/yyyy - HH:mm";
public static final String HOUR_FORMAT = "HH:mm";
......
......@@ -41,7 +41,7 @@ public class AccountPresenter extends BasePresenter<AccountView> {
this.context = context;
this.accountPresenter = this;
this.isPicUpdate = false;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
private void onSuccessfulCheck(AccountOutput accountOutput, Headers headers){
......
......@@ -68,15 +68,15 @@ public abstract class BasePresenter<V> {
protected void updateHeaders(Headers headers) {
if(osb == null && context != null)
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
if(headers.get(Utils.ACCESS_TOKEN) != null)
if(headers.get(Utils.ACCESS_TOKEN) != null && headers.get(Utils.ACCESS_TOKEN).compareTo("") != 0)
osb.edit().putString(Utils.ACCESS_TOKEN, headers.get(Utils.ACCESS_TOKEN)).apply();
if(headers.get(Utils.CLIENT) != null)
if(headers.get(Utils.CLIENT) != null && headers.get(Utils.CLIENT).compareTo("") != 0)
osb.edit().putString(Utils.CLIENT, headers.get(Utils.CLIENT)).apply();
if(headers.get(Utils.UID) != null)
if(headers.get(Utils.UID) != null && headers.get(Utils.UID).compareTo("") != 0)
osb.edit().putString(Utils.UID, headers.get(Utils.UID)).apply();
if(headers.get(Utils.EXPIRY) != null)
if(headers.get(Utils.EXPIRY) != null && headers.get(Utils.EXPIRY).compareTo("") != 0)
osb.edit().putString(Utils.EXPIRY, headers.get(Utils.EXPIRY)).apply();
}
......@@ -87,7 +87,7 @@ public abstract class BasePresenter<V> {
dispatcher.cancel(Utils.NOTIFICATION_UPDATE_LIST_SERVICE);
if(osb == null)
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
Gson gson = new Gson();
......
......@@ -30,7 +30,7 @@ public class CitizensPresenter extends BasePresenter<CitizenListActivity> {
public CitizensPresenter(Context context){
citizensPresenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
@Override
......
......@@ -36,7 +36,7 @@ public class DependentUpdatePresenter extends BasePresenter<DependentUpdateActiv
public DependentUpdatePresenter(Context context){
presenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......
......@@ -47,7 +47,7 @@ public class DependentsListPresenter extends BasePresenter<DependentsListActivit
public DependentsListPresenter(Context context){
presenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......
......@@ -33,7 +33,7 @@ public class EmailActPresenter extends BasePresenter<EmailActView>{
public EmailActPresenter(Context context) {
this.context = context;
this.presenter = this;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
public void updateEmail(AccountUpdate accountUpdate){
......
......@@ -32,7 +32,7 @@ public class HomePresenter extends BasePresenter<HomeView> {
public HomePresenter(Context context) {
this.context = context;
this.homePresenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
@Override
......
......@@ -60,7 +60,7 @@ public class LoginPresenter extends BasePresenter<LoginView> {
dispatcher = new FirebaseJobDispatcher(
new GooglePlayDriver(context)
);
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
@Override
......
......@@ -45,7 +45,7 @@ public class MainPresenter extends BasePresenter<MainView>{
"Agendador", Context.MODE_PRIVATE);
String expiry = osb.getString("expiry", null);
if (expiry == null) {
if (expiry == null || expiry.compareTo("") == 0) {
return -1;
}
......
......@@ -36,7 +36,7 @@ public class NewDependentPresenter extends BasePresenter<NewDependentActivity> {
public NewDependentPresenter(Context context){
presenter = this;
this.context = context;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......@@ -57,7 +57,7 @@ public class NewDependentPresenter extends BasePresenter<NewDependentActivity> {
data.getData().setImage(body.get(Utils.PHOTO_TYPE), body.get(Utils.PHOTO_NAME), body.get(Utils.PHOTO_CONTENT));
}
Call<FullDependent> listCall = service.createNewDependent(osb.getLong("id", 0), data);
Call<FullDependent> listCall = service.createNewDependent(osb.getLong(Utils.ID, 0), data);
presenter.view().setProgressBar(true);
listCall.enqueue(new Callback<FullDependent>() {
......
......@@ -31,16 +31,10 @@ public class ScheduleConfirmationPresenter extends BasePresenter<ScheduleConfirm
private ScheduleConfirmationPresenter scheduleConfirmationPresenter;
private FirebaseJobDispatcher dispatcher;
public ScheduleConfirmationPresenter(Context context){
this.context = context;
this.scheduleConfirmationPresenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
dispatcher = new FirebaseJobDispatcher(
new GooglePlayDriver(context)
);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......
......@@ -31,7 +31,7 @@ public class ScheduleInfoPresenter extends BasePresenter<ScheduleInfoActivity> {
public ScheduleInfoPresenter(Context context) {
this.context = context;
presenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......
......@@ -29,7 +29,7 @@ public class SchedulesHistoryPresenter extends BasePresenter<SchedulesHistoryAct
public SchedulesHistoryPresenter(Context context) {
this.context = context;
this.presenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......
......@@ -34,7 +34,7 @@ public class SchedulesPresenter extends BasePresenter<SchedulesActivity> {
public SchedulesPresenter(Context context){
this.context = context;
this.presenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
......
......@@ -34,7 +34,7 @@ public class SchedulingPresenter extends BasePresenter<SchedulingView> {
public SchedulingPresenter(Context context){
this.context = context;
this.schedulingPresenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
@Override
......
......@@ -30,7 +30,7 @@ public class SignUpPresenter extends BasePresenter<SignupView> {
public SignUpPresenter(Context context) {
this.context = context;
this.signUpPresenter = this;
this.osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
this.osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
@Override
......
......@@ -32,7 +32,7 @@ public class TermPresenter extends BasePresenter<TermActivity>{
public TermPresenter(Context context){
this.context = context;
termPresenter = this;
osb = ObscuredSharedPreferences.getPrefs(context, "Agendador", Context.MODE_PRIVATE);
osb = ObscuredSharedPreferences.getPrefs(context, Utils.APP_NAME, Context.MODE_PRIVATE);
}
@Override
......
......@@ -83,7 +83,7 @@ public class NotificationsListService extends JobService {
Gson gson = new Gson();
LongSparseArray<NotificationReturn> newLocalNotifications = new LongSparseArray<>();
List<NotificationReturn> list = LocalNotificationManager.getList(osb, gson);
Log.d("Notificacao", "NOTIFICACOES LOCAIS!!!!!!!!!");
Log.d("l", "NOTIFICACOES LOCAIS!!!!!!!!!");
for(NotificationReturn n : list){
newLocalNotifications.append(n.notificationId, n);
Log.d("Notificacao", gson.toJson(n));
......
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