mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
fix various linter errors
This commit is contained in:
parent
11589f2cc5
commit
3283cd8187
32 changed files with 201 additions and 214 deletions
|
|
@ -237,7 +237,6 @@ Severity: EASY
|
|||
<!-- See http://checkstyle.sourceforge.net/config_misc.html -->
|
||||
<module name="ArrayTypeStyle" />
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="Indentation"/>
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="TodoComment">
|
||||
<property name="format" value="(?i)\s+TODO\s+" />
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@
|
|||
<string name="byLeader" >by %s</string>
|
||||
<string name="challenge_details">Challenge Details</string>
|
||||
<string name="challenge_leave_title">Leave Challenge</string>
|
||||
<string name="challenge_leave_text" formatted="false">Are you sure you want to leave the Challenge “%s”?</string>
|
||||
<string name="challenge_leave_text">Are you sure you want to leave the Challenge “%s”?</string>
|
||||
<string name="challenge_remove_tasks_title">Remove tasks</string>
|
||||
<string name="challenge_remove_tasks_text">Do you want to remove the tasks?</string>
|
||||
<string name="remove_tasks">Remove</string>
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import com.habitrpg.android.habitica.components.AppComponent;
|
|||
import com.habitrpg.android.habitica.components.DaggerAppComponent;
|
||||
import com.habitrpg.android.habitica.modules.AppModule;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class HabiticaApplication extends HabiticaBaseApplication {
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import com.amplitude.api.Amplitude;
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import com.amplitude.api.Amplitude;
|
||||
import com.habitrpg.android.habitica.database.CheckListItemExcludeStrategy;
|
||||
import com.habitrpg.android.habitica.helpers.PopupNotificationsManager;
|
||||
import com.habitrpg.android.habitica.proxy.ifce.CrashlyticsProxy;
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.ApiService;
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.ApiClient;
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.ApiService;
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.Server;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.AchievementResult;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Challenge;
|
||||
|
|
@ -26,16 +28,14 @@ import com.magicmicky.habitrpgwrapper.lib.models.LeaveChallengeBody;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.PostChatMessageResult;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.PurchaseValidationRequest;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.PurchaseValidationResult;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Purchases;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Quest;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Shop;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Skill;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Status;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.SubscriptionValidationRequest;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Tag;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TaskDirectionData;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.BuyResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.HabitResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Purchases;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Skill;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.TutorialStep;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.UserAuth;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.UserAuthResponse;
|
||||
|
|
@ -47,7 +47,9 @@ import com.magicmicky.habitrpgwrapper.lib.models.inventory.HatchingPotion;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Mount;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.Pet;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.QuestContent;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.BuyResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.FeedResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.HabitResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.SkillResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.responses.UnlockResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.ChecklistItem;
|
||||
|
|
@ -82,10 +84,6 @@ import com.magicmicky.habitrpgwrapper.lib.utils.TaskTagDeserializer;
|
|||
import com.magicmicky.habitrpgwrapper.lib.utils.TutorialStepListDeserializer;
|
||||
import com.raizlabs.android.dbflow.structure.ModelAdapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -94,7 +92,6 @@ import java.net.SocketTimeoutException;
|
|||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -120,6 +117,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
private final GsonConverterFactory gsonConverter;
|
||||
private final HostConfig hostConfig;
|
||||
private final Retrofit retrofitAdapter;
|
||||
private final PopupNotificationsManager popupNotificationsManager;
|
||||
|
||||
private CrashlyticsProxy crashlyticsProxy;
|
||||
private Context context;
|
||||
|
|
@ -127,13 +125,12 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
// I think we don't need the ApiClientImpl anymore we could just use ApiService
|
||||
private final ApiService apiService;
|
||||
|
||||
final Observable.Transformer apiCallTransformer =
|
||||
private final Observable.Transformer apiCallTransformer =
|
||||
observable -> ((Observable) observable)
|
||||
.map(new Func1<HabitResponse, Object>() {
|
||||
@Override
|
||||
public Object call(HabitResponse habitResponse) {
|
||||
if (habitResponse.notifications != null) {
|
||||
PopupNotificationsManager popupNotificationsManager = PopupNotificationsManager.getInstance(com.habitrpg.android.habitica.ApiClientImpl.this, context);
|
||||
popupNotificationsManager.showNotificationDialog(habitResponse.notifications);
|
||||
}
|
||||
return habitResponse.getData();
|
||||
|
|
@ -147,10 +144,12 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
|
||||
//private OnHabitsAPIResult mResultListener;
|
||||
//private HostConfig mConfig;
|
||||
public ApiClientImpl(GsonConverterFactory gsonConverter, HostConfig hostConfig, CrashlyticsProxy crashlyticsProxy, Context context) {
|
||||
public ApiClientImpl(GsonConverterFactory gsonConverter, HostConfig hostConfig, CrashlyticsProxy crashlyticsProxy, PopupNotificationsManager popupNotificationsManager, Context context) {
|
||||
this.gsonConverter = gsonConverter;
|
||||
this.hostConfig = hostConfig;
|
||||
this.context = context;
|
||||
this.crashlyticsProxy = crashlyticsProxy;
|
||||
this.popupNotificationsManager = popupNotificationsManager;
|
||||
|
||||
HabiticaBaseApplication.getComponent().inject(this);
|
||||
crashlyticsProxy.setUserIdentifier(this.hostConfig.getUser());
|
||||
|
|
@ -217,9 +216,9 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
}.getType();
|
||||
Type questContentListType = new TypeToken<List<QuestContent>>() {
|
||||
}.getType();
|
||||
Type petListType = new TypeToken<HashMap<String, Pet>>() {
|
||||
Type petListType = new TypeToken<Map<String, Pet>>() {
|
||||
}.getType();
|
||||
Type mountListType = new TypeToken<HashMap<String, Mount>>() {
|
||||
Type mountListType = new TypeToken<Map<String, Mount>>() {
|
||||
}.getType();
|
||||
|
||||
//Exclusion strategy needed for DBFlow https://github.com/Raizlabs/DBFlow/issues/121
|
||||
|
|
@ -227,8 +226,8 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
.setExclusionStrategies(new CheckListItemExcludeStrategy())
|
||||
.setExclusionStrategies(new ExclusionStrategy() {
|
||||
@Override
|
||||
public boolean shouldSkipField(FieldAttributes f) {
|
||||
return f.getDeclaredClass().equals(ModelAdapter.class);
|
||||
public boolean shouldSkipField(FieldAttributes field) {
|
||||
return field.getDeclaredClass().equals(ModelAdapter.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -355,18 +354,20 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
habitRPGUser.setRewards(sortTasks(tasks.tasks, habitRPGUser.getTasksOrder().getRewards()));
|
||||
for (Task task : tasks.tasks.values()) {
|
||||
switch (task.getType()) {
|
||||
case "habit":
|
||||
case Task.TYPE_HABIT:
|
||||
habitRPGUser.getHabits().add(task);
|
||||
break;
|
||||
case "daily":
|
||||
case Task.TYPE_DAILY:
|
||||
habitRPGUser.getDailys().add(task);
|
||||
break;
|
||||
case "todo":
|
||||
case Task.TYPE_TODO:
|
||||
habitRPGUser.getTodos().add(task);
|
||||
break;
|
||||
case "reward":
|
||||
case Task.TYPE_REWARD:
|
||||
habitRPGUser.getRewards().add(task);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -400,10 +401,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
}
|
||||
|
||||
private void showConnectionProblemDialog(final int resourceTitleString, final int resourceMessageString) {
|
||||
Activity currentActivity = HabiticaApplication.currentActivity;
|
||||
if (currentActivity != null) {
|
||||
showConnectionProblemDialog(currentActivity.getString(resourceTitleString), currentActivity.getString(resourceMessageString));
|
||||
}
|
||||
showConnectionProblemDialog(context.getString(resourceTitleString), context.getString(resourceMessageString));
|
||||
}
|
||||
|
||||
private void showConnectionProblemDialog(final String resourceTitleString, final String resourceMessageString) {
|
||||
|
|
@ -447,7 +445,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
|
||||
@Override
|
||||
public void setLanguageCode(String languageCode) {
|
||||
this.languageCode = languageCode;
|
||||
this.languageCode = languageCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -498,7 +496,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Observable<Void> validateSubscription(SubscriptionValidationRequest request){
|
||||
public Observable<Void> validateSubscription(SubscriptionValidationRequest request) {
|
||||
return apiService.validateSubscription(request).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
|
|
@ -669,7 +667,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Observable<PostChatMessageResult> postGroupChat(String groupId, HashMap<String, String> message) {
|
||||
public Observable<PostChatMessageResult> postGroupChat(String groupId, Map<String, String> message) {
|
||||
return apiService.postGroupChat(groupId, message).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
|
|
@ -730,7 +728,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
|
||||
@Override
|
||||
public Observable<Quest> forceStartQuest(String groupId, Group group) {
|
||||
return apiService.forceStartQuest(groupId,group).compose(configureApiCallObserver());
|
||||
return apiService.forceStartQuest(groupId, group).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -759,17 +757,17 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Observable<HabitRPGUser> GetMember(String memberId) {
|
||||
return apiService.GetMember(memberId).compose(configureApiCallObserver());
|
||||
public Observable<HabitRPGUser> getMember(String memberId) {
|
||||
return apiService.getMember(memberId).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<AchievementResult> GetMemberAchievements(String memberId) {
|
||||
return apiService.GetMemberAchievements(memberId).compose(configureApiCallObserver());
|
||||
public Observable<AchievementResult> getMemberAchievements(String memberId) {
|
||||
return apiService.getMemberAchievements(memberId).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<PostChatMessageResult> postPrivateMessage(HashMap<String, String> messageDetails) {
|
||||
public Observable<PostChatMessageResult> postPrivateMessage(Map<String, String> messageDetails) {
|
||||
return apiService.postPrivateMessage(messageDetails).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
|
|
@ -823,7 +821,7 @@ public class ApiClientImpl implements Action1<Throwable>, ApiClient {
|
|||
return apiService.readNotification(notificationId).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
public Observable<ContentResult>getContent() {
|
||||
public Observable<ContentResult> getContent() {
|
||||
return apiService.getContent(languageCode).compose(configureApiCallObserver());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.ApiClient;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.QuestBoss;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.inventory.QuestContent;
|
||||
|
|
@ -11,11 +13,14 @@ import com.raizlabs.android.dbflow.sql.language.Where;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import rx.Observable;
|
||||
|
||||
|
||||
public class ContentCache {
|
||||
private static final String CONTENT_TYPE_ITEM = "item";
|
||||
private static final String CONTENT_TYPE_QUEST = "quest";
|
||||
private ApiClient apiClient;
|
||||
|
||||
|
||||
|
|
@ -23,36 +28,31 @@ public class ContentCache {
|
|||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
public void GetQuestContent(final String key, final QuestContentCallback cb) {
|
||||
final QuestContent quest = new Select().from(QuestContent.class).where(Condition.column("key").eq(key)).querySingle();
|
||||
public void getQuestContent(final String key, final QuestContentCallback cb) {
|
||||
final QuestContent quest = new Select().from(QuestContent.class).where(Condition.column(ItemData.UNIQUE_IDENTIFIER).eq(key)).querySingle();
|
||||
|
||||
if (quest != null) {
|
||||
quest.boss = new Select().from(QuestBoss.class).where(Condition.column("key").eq(key)).querySingle();
|
||||
cb.GotQuest(quest);
|
||||
quest.boss = new Select().from(QuestBoss.class).where(Condition.column(ItemData.UNIQUE_IDENTIFIER).eq(key)).querySingle();
|
||||
cb.gotQuest(quest);
|
||||
} else {
|
||||
|
||||
getContentAndSearchFor("quest", key, new GotContentEntryCallback<QuestContent>() {
|
||||
@Override
|
||||
public void GotObject(QuestContent obj) {
|
||||
cb.GotQuest(obj);
|
||||
}
|
||||
});
|
||||
getContentAndSearchFor(CONTENT_TYPE_QUEST, key, cb::gotQuest);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetItemData(final String key, final GotContentEntryCallback<ItemData> gotEntry) {
|
||||
final ItemData itemData = new Select().from(ItemData.class).where(Condition.column("key").eq(key)).querySingle();
|
||||
public void getItemData(final String key, final GotContentEntryCallback<ItemData> gotEntry) {
|
||||
final ItemData itemData = new Select().from(ItemData.class).where(Condition.column(ItemData.UNIQUE_IDENTIFIER).eq(key)).querySingle();
|
||||
|
||||
if (itemData != null) {
|
||||
gotEntry.GotObject(itemData);
|
||||
gotEntry.gotObject(itemData);
|
||||
} else {
|
||||
getContentAndSearchFor("item", key, gotEntry);
|
||||
getContentAndSearchFor(CONTENT_TYPE_ITEM, key, gotEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetItemDataList(final List<String> keysToSearch, GotContentEntryCallback<List<ItemData>> gotEntries) {
|
||||
public void getItemDataList(final List<String> keysToSearch, GotContentEntryCallback<List<ItemData>> gotEntries) {
|
||||
|
||||
Condition.In keyCondition = Condition.column("key").in("");
|
||||
Condition.In keyCondition = Condition.column(ItemData.UNIQUE_IDENTIFIER).in("");
|
||||
|
||||
for (String item : keysToSearch) {
|
||||
keyCondition = keyCondition.and(item);
|
||||
|
|
@ -63,9 +63,9 @@ public class ContentCache {
|
|||
List<ItemData> items = query.queryList();
|
||||
|
||||
if (items != null && items.size() == keysToSearch.size()) {
|
||||
gotEntries.GotObject(items);
|
||||
gotEntries.gotObject(items);
|
||||
} else {
|
||||
getContentAndSearchForList("item", keysToSearch, gotEntries);
|
||||
getContentAndSearchForList(keysToSearch, gotEntries);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -74,23 +74,23 @@ public class ContentCache {
|
|||
|
||||
.subscribe(contentResult -> {
|
||||
switch (typeOfSearch) {
|
||||
case "quest": {
|
||||
case CONTENT_TYPE_QUEST: {
|
||||
Collection<QuestContent> questList = contentResult.quests;
|
||||
|
||||
for (QuestContent quest : questList) {
|
||||
if (quest.getKey().equals(searchKey)) {
|
||||
gotEntry.GotObject((T) quest);
|
||||
gotEntry.gotObject((T) quest);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case "item": {
|
||||
case CONTENT_TYPE_ITEM: {
|
||||
T searchedItem = null;
|
||||
|
||||
if (searchKey.equals("potion")) {
|
||||
if ("potion".equals(searchKey)) {
|
||||
searchedItem = (T) contentResult.potion;
|
||||
} else if (searchKey == "armoire") {
|
||||
} else if ("armoire".equals(searchKey)) {
|
||||
searchedItem = (T) contentResult.armoire;
|
||||
} else {
|
||||
Collection<ItemData> itemList = contentResult.gear.flat;
|
||||
|
|
@ -102,35 +102,37 @@ public class ContentCache {
|
|||
}
|
||||
}
|
||||
|
||||
gotEntry.GotObject(searchedItem);
|
||||
gotEntry.gotObject(searchedItem);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}, throwable -> {
|
||||
});
|
||||
}
|
||||
|
||||
private void getContentAndSearchForList(final String typeOfSearch, final List<String> searchKeys, final GotContentEntryCallback<List<ItemData>> gotEntry) {
|
||||
private void getContentAndSearchForList(final List<String> searchKeys, final GotContentEntryCallback<List<ItemData>> gotEntry) {
|
||||
List<ItemData> resultList = new ArrayList<>();
|
||||
apiClient.getContent()
|
||||
|
||||
.flatMap(contentResult -> {
|
||||
List<ItemData> itemList = new ArrayList<ItemData>(contentResult.gear.flat);
|
||||
List<ItemData> itemList = new ArrayList<>(contentResult.gear.flat);
|
||||
itemList.add(contentResult.potion);
|
||||
itemList.add(contentResult.armoire);
|
||||
return Observable.from(itemList);
|
||||
})
|
||||
.filter(item -> searchKeys.contains(item.key))
|
||||
.subscribe(resultList::add, throwable -> {
|
||||
}, () -> gotEntry.GotObject(resultList));
|
||||
}, () -> gotEntry.gotObject(resultList));
|
||||
}
|
||||
|
||||
public interface GotContentEntryCallback<T extends Object> {
|
||||
void GotObject(T obj);
|
||||
void gotObject(@Nullable T obj);
|
||||
}
|
||||
|
||||
public interface QuestContentCallback {
|
||||
void GotQuest(QuestContent content);
|
||||
void gotQuest(QuestContent content);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,8 @@ public class HabitDatabase {
|
|||
public static final String NAME = "Habitica";
|
||||
|
||||
public static final int VERSION = 34;
|
||||
|
||||
public HabitDatabase() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,5 @@
|
|||
package com.habitrpg.android.habitica;
|
||||
|
||||
import com.amplitude.api.Amplitude;
|
||||
import com.facebook.FacebookSdk;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.habitrpg.android.habitica.components.AppComponent;
|
||||
import com.habitrpg.android.habitica.proxy.ifce.CrashlyticsProxy;
|
||||
import com.habitrpg.android.habitica.ui.activities.IntroActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.LoginActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.SetupActivity;
|
||||
import com.habitrpg.android.habitica.ui.activities.TaskFormActivity;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.raizlabs.android.dbflow.config.FlowManager;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import com.squareup.leakcanary.RefWatcher;
|
||||
|
||||
import org.solovyev.android.checkout.Billing;
|
||||
import org.solovyev.android.checkout.Cache;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
import org.solovyev.android.checkout.PurchaseVerifier;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
|
@ -26,19 +7,13 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.content.res.Resources;
|
||||
import android.database.DatabaseErrorHandler;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.util.Log;
|
||||
|
||||
|
|
@ -62,7 +37,6 @@ import org.solovyev.android.checkout.PurchaseVerifier;
|
|||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
|
@ -84,14 +58,12 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
/**
|
||||
* For better performance billing class should be used as singleton
|
||||
*/
|
||||
@NonNull
|
||||
private Billing billing;
|
||||
/**
|
||||
* Application wide {@link Checkout} instance (can be used
|
||||
* anywhere in the app).
|
||||
* This instance contains all available products in the app.
|
||||
*/
|
||||
@NonNull
|
||||
private Checkout checkout;
|
||||
|
||||
public static HabiticaBaseApplication getInstance(Context context) {
|
||||
|
|
@ -108,7 +80,7 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
}
|
||||
}
|
||||
|
||||
private static void setFinalStatic(Field field, Object newValue) throws NoSuchFieldException, IllegalAccessException {
|
||||
private static void setFinalStatic(Field field, @Nullable Object newValue) throws NoSuchFieldException, IllegalAccessException {
|
||||
field.setAccessible(true);
|
||||
field.set(null, newValue);
|
||||
}
|
||||
|
|
@ -264,8 +236,9 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
if (currentActivity == activity)
|
||||
if (currentActivity.equals(activity)) {
|
||||
currentActivity = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -336,9 +309,7 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
|
||||
@Override
|
||||
public File getDatabasePath(String name) {
|
||||
File dbFile = new File(getExternalFilesDir(null), "HabiticaDatabase/" + name);
|
||||
//Crashlytics.setString("Database File", dbFile.getAbsolutePath());
|
||||
return dbFile;
|
||||
return new File(getExternalFilesDir(null), "HabiticaDatabase/" + name);
|
||||
}
|
||||
|
||||
private void createBillingAndCheckout() {
|
||||
|
|
@ -355,6 +326,7 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
return Billing.newCache();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public PurchaseVerifier getPurchaseVerifier() {
|
||||
return new HabiticaPurchaseVerifier(HabiticaBaseApplication.this, lazyApiHelper.get());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -25,31 +26,27 @@ import java.util.Map;
|
|||
*/
|
||||
|
||||
public class PopupNotificationsManager {
|
||||
private static PopupNotificationsManager instance;
|
||||
private Map<String, Boolean> seenNotifications;
|
||||
@Nullable
|
||||
private ApiClient apiClient;
|
||||
private Context context;
|
||||
|
||||
// @TODO: A queue for displaying alert dialogues
|
||||
|
||||
private PopupNotificationsManager(ApiClient apiClient, Context context) {
|
||||
this.apiClient = apiClient;
|
||||
public PopupNotificationsManager(Context context) {
|
||||
this.seenNotifications = new HashMap<>();
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public static PopupNotificationsManager getInstance(ApiClient apiHelper, Context context) {
|
||||
if (instance == null) {
|
||||
instance = new PopupNotificationsManager(apiHelper, context);
|
||||
}
|
||||
return instance;
|
||||
public void setApiClient(@Nullable ApiClient apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
public Boolean displayNotification(Notification notification) {
|
||||
Boolean displayNotification(Notification notification) {
|
||||
String title = notification.data.message;
|
||||
String youEarnedMessage = "";
|
||||
|
||||
LayoutInflater factory = LayoutInflater.from(HabiticaApplication.currentActivity);
|
||||
LayoutInflater factory = LayoutInflater.from(context);
|
||||
final View view = factory.inflate(R.layout.dialog_login_incentive, null);
|
||||
|
||||
SimpleDraweeView imageView = (SimpleDraweeView) view.findViewById(R.id.imageView);
|
||||
|
|
@ -89,17 +86,14 @@ public class PopupNotificationsManager {
|
|||
final AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
|
||||
confirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (apiClient != null) {
|
||||
// @TODO: This should be handled somewhere else? MAybe we notifiy via event
|
||||
apiClient.readNotificaiton(notification.getId())
|
||||
.subscribe(next -> {}, throwable -> {});
|
||||
}
|
||||
|
||||
dialog.hide();
|
||||
confirmButton.setOnClickListener(view1 -> {
|
||||
if (apiClient != null) {
|
||||
// @TODO: This should be handled somewhere else? MAybe we notifiy via event
|
||||
apiClient.readNotificaiton(notification.getId())
|
||||
.subscribe(next -> {}, throwable -> {});
|
||||
}
|
||||
|
||||
dialog.hide();
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -18,10 +21,12 @@ import rx.schedulers.Schedulers;
|
|||
|
||||
// based on http://stackoverflow.com/questions/29838565/downloading-files-using-okhttp-okio-and-rxjava
|
||||
public class SoundFileLoader {
|
||||
OkHttpClient client;
|
||||
private final Context context;
|
||||
private OkHttpClient client;
|
||||
|
||||
public SoundFileLoader() {
|
||||
public SoundFileLoader(Context context) {
|
||||
client = new OkHttpClient();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Observable<List<SoundFile>> download(List<SoundFile> files) {
|
||||
|
|
@ -70,8 +75,14 @@ public class SoundFileLoader {
|
|||
.map(ArrayList::new);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getExternalCacheDir() {
|
||||
return HabiticaApplication.getInstance(HabiticaApplication.currentActivity).getExternalCacheDir().getPath();
|
||||
File cacheDir = HabiticaApplication.getInstance(context).getExternalCacheDir();
|
||||
if (cacheDir != null) {
|
||||
return cacheDir.getPath();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFullAudioFilePath(SoundFile soundFile) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.habitrpg.android.habitica.helpers;
|
||||
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
|
||||
import android.media.MediaPlayer;
|
||||
import com.habitrpg.android.habitica.HabiticaBaseApplication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -29,12 +27,10 @@ public class SoundManager {
|
|||
SoundFileLoader soundFileLoader;
|
||||
private String soundTheme;
|
||||
|
||||
private MediaPlayer mp = new MediaPlayer();
|
||||
|
||||
private HashMap<String, SoundFile> loadedSoundFiles;
|
||||
|
||||
public SoundManager() {
|
||||
HabiticaApplication.getInstance(HabiticaApplication.currentActivity).getComponent().inject(this);
|
||||
HabiticaBaseApplication.getComponent().inject(this);
|
||||
|
||||
loadedSoundFiles = new HashMap<>();
|
||||
}
|
||||
|
|
@ -84,7 +80,7 @@ public class SoundManager {
|
|||
loadedSoundFiles.put(type, file);
|
||||
file.play();
|
||||
|
||||
}, throwable -> throwable.printStackTrace());
|
||||
}, Throwable::printStackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.habitrpg.android.habitica.modules;
|
||||
|
||||
import com.habitrpg.android.habitica.helpers.PopupNotificationsManager;
|
||||
import com.habitrpg.android.habitica.proxy.ifce.CrashlyticsProxy;
|
||||
import com.magicmicky.habitrpgwrapper.lib.api.ApiClient;
|
||||
import com.habitrpg.android.habitica.ContentCache;
|
||||
|
|
@ -33,8 +34,14 @@ public class ApiModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public ApiClient providesApiHelper(GsonConverterFactory gsonConverter, HostConfig hostConfig, CrashlyticsProxy crashlyticsProxy, Context context) {
|
||||
return new com.habitrpg.android.habitica.ApiClientImpl(gsonConverter, hostConfig, crashlyticsProxy, context);
|
||||
public PopupNotificationsManager providesPopupNotificationsManager(Context context) {
|
||||
return new PopupNotificationsManager(context);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public ApiClient providesApiHelper(GsonConverterFactory gsonConverter, HostConfig hostConfig, CrashlyticsProxy crashlyticsProxy, PopupNotificationsManager popupNotificationsManager, Context context) {
|
||||
return new com.habitrpg.android.habitica.ApiClientImpl(gsonConverter, hostConfig, crashlyticsProxy, popupNotificationsManager, context);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class AppModule {
|
|||
@Provides
|
||||
@Named("UserID")
|
||||
public String providesUserID(SharedPreferences sharedPreferences) {
|
||||
return sharedPreferences.getString(application.getString(R.string.SP_userID), null);
|
||||
return sharedPreferences.getString(application.getString(R.string.SP_userID), "");
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
@ -60,8 +60,8 @@ public class AppModule {
|
|||
}
|
||||
|
||||
@Provides
|
||||
public SoundFileLoader providesSoundFileLoader() {
|
||||
return new SoundFileLoader();
|
||||
public SoundFileLoader providesSoundFileLoader(Context context) {
|
||||
return new SoundFileLoader(context);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class MaxHeightLinearLayout extends LinearLayout {
|
|||
|
||||
private final float defaultHeight = 0.9f;
|
||||
private float maxHeight;
|
||||
private DisplayMetrics displaymetrics = new DisplayMetrics();
|
||||
|
||||
public MaxHeightLinearLayout(Context context) {
|
||||
super(context);
|
||||
|
|
@ -58,9 +59,8 @@ public class MaxHeightLinearLayout extends LinearLayout {
|
|||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
|
||||
if (HabiticaApplication.currentActivity != null) {
|
||||
DisplayMetrics displaymetrics = new DisplayMetrics();
|
||||
HabiticaApplication.currentActivity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
|
||||
int height = (int) ((int) displaymetrics.heightPixels * maxHeight);
|
||||
int height = (int) (displaymetrics.heightPixels * maxHeight);
|
||||
|
||||
heightMeasureSpec = Math.min(heightMeasureSpec, View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import com.habitrpg.android.habitica.interactors.DisplayItemDropUseCase;
|
|||
import com.habitrpg.android.habitica.interactors.HabitScoreUseCase;
|
||||
import com.habitrpg.android.habitica.interactors.NotifyUserUseCase;
|
||||
import com.habitrpg.android.habitica.interactors.TodoCheckUseCase;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallegeDetailDialogHolder;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengeDetailDialogHolder;
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.challenges.ChallengeTasksRecyclerViewFragment;
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
|
||||
import com.habitrpg.android.habitica.ui.helpers.UiUtils;
|
||||
|
|
@ -337,7 +337,7 @@ public class ChallengeDetailActivity extends BaseActivity {
|
|||
@OnClick(R.id.btn_show_more)
|
||||
void onShowMore() {
|
||||
|
||||
ChallegeDetailDialogHolder.showDialog(ChallengeDetailActivity.this, ChallengeDetailActivity.this.apiClient,
|
||||
ChallengeDetailDialogHolder.showDialog(ChallengeDetailActivity.this, ChallengeDetailActivity.this.apiClient,
|
||||
HabiticaApplication.User, challenge,
|
||||
challenge1 -> {
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class FullProfileActivity extends BaseActivity {
|
|||
|
||||
setTitle(R.string.profile_loading_data);
|
||||
|
||||
apiClient.GetMember(this.userId)
|
||||
apiClient.getMember(this.userId)
|
||||
|
||||
.subscribe(this::updateView,
|
||||
throwable -> {
|
||||
|
|
@ -248,7 +248,7 @@ public class FullProfileActivity extends BaseActivity {
|
|||
mountsTamedCount.setText(String.valueOf(user.getMountsTamedCount()));
|
||||
|
||||
// Load the members achievements now
|
||||
apiClient.GetMemberAchievements(this.userId)
|
||||
apiClient.getMemberAchievements(this.userId)
|
||||
|
||||
.subscribe(this::fillAchievements,
|
||||
throwable -> {
|
||||
|
|
@ -375,7 +375,7 @@ public class FullProfileActivity extends BaseActivity {
|
|||
outfitList.add(outfit.getShield());
|
||||
outfitList.add(outfit.getWeapon());
|
||||
|
||||
contentCache.GetItemDataList(outfitList, gotEntries);
|
||||
contentCache.getItemDataList(outfitList, gotEntries);
|
||||
}
|
||||
|
||||
public void gotGear(List<ItemData> itemDataList, HabitRPGUser user) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class AchievementAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
public MainActivity activity;
|
||||
private List<Object> itemList;
|
||||
|
||||
public <T extends Achievement> void setItemList(List<Object> itemList) {
|
||||
public void setItemList(List<Object> itemList) {
|
||||
this.itemList = itemList;
|
||||
this.notifyDataSetChanged();
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ public class AchievementAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||
|
||||
Resources resources;
|
||||
|
||||
public AchievementViewHolder(View itemView) {
|
||||
AchievementViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class RewardsRecyclerViewAdapter extends BaseTasksRecyclerViewAdapter<Rew
|
|||
itemKeys.add("armoire");
|
||||
}
|
||||
return Observable.create((Observable.OnSubscribe<List<Task>>) subscriber -> {
|
||||
contentCache.GetItemDataList(itemKeys, obj -> {
|
||||
contentCache.getItemDataList(itemKeys, obj -> {
|
||||
ArrayList<Task> buyableItems = new ArrayList<>();
|
||||
for (ItemData item : obj) {
|
||||
Task reward = new Task();
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ public class ChatListFragment extends BaseFragment implements SwipeRefreshLayout
|
|||
}, throwable -> {
|
||||
});
|
||||
|
||||
UiUtils.dismissKeyboard(HabiticaApplication.currentActivity);
|
||||
UiUtils.dismissKeyboard(getActivity());
|
||||
}
|
||||
|
||||
// If the ChatList is Tavern, we're able to toggle the sleep-mode
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public class InboxMessageListFragment extends BaseMainFragment
|
|||
}, throwable -> {
|
||||
});
|
||||
|
||||
UiUtils.dismissKeyboard(HabiticaApplication.currentActivity);
|
||||
UiUtils.dismissKeyboard(getActivity());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class TavernFragment extends BaseMainFragment {
|
|||
TavernFragment.this.tabLayout.setupWithViewPager(TavernFragment.this.viewPager);
|
||||
}
|
||||
|
||||
contentCache.GetQuestContent(group.quest.key, content -> {
|
||||
contentCache.getQuestContent(group.quest.key, content -> {
|
||||
if (questInfoFragment != null) {
|
||||
questInfoFragment.setQuestContent(content);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.commands.OpenFullProfileCommand;
|
||||
import com.habitrpg.android.habitica.ui.activities.ChallengeDetailActivity;
|
||||
|
|
@ -36,7 +35,7 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnClick;
|
||||
import rx.functions.Action1;
|
||||
|
||||
public class ChallegeDetailDialogHolder {
|
||||
public class ChallengeDetailDialogHolder {
|
||||
|
||||
@BindView(R.id.challenge_not_joined_header)
|
||||
LinearLayout notJoinedHeader;
|
||||
|
|
@ -78,7 +77,7 @@ public class ChallegeDetailDialogHolder {
|
|||
private Activity context;
|
||||
|
||||
|
||||
private ChallegeDetailDialogHolder(View view, Activity context) {
|
||||
private ChallengeDetailDialogHolder(View view, Activity context) {
|
||||
this.context = context;
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
|
|
@ -87,12 +86,12 @@ public class ChallegeDetailDialogHolder {
|
|||
Action1<Challenge> challengeJoinedAction, Action1<Challenge> challengeLeftAction) {
|
||||
View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_challenge_detail, null);
|
||||
|
||||
ChallegeDetailDialogHolder challegeDetailDialogHolder = new ChallegeDetailDialogHolder(dialogLayout, activity);
|
||||
ChallengeDetailDialogHolder challengeDetailDialogHolder = new ChallengeDetailDialogHolder(dialogLayout, activity);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity)
|
||||
.setView(dialogLayout);
|
||||
|
||||
challegeDetailDialogHolder.bind(builder.show(), apiClient, user, challenge, challengeJoinedAction, challengeLeftAction);
|
||||
challengeDetailDialogHolder.bind(builder.show(), apiClient, user, challenge, challengeJoinedAction, challengeLeftAction);
|
||||
}
|
||||
|
||||
public void bind(AlertDialog dialog, ApiClient apiClient, @Nullable HabitRPGUser user, Challenge challenge,
|
||||
|
|
@ -279,7 +278,7 @@ public class ChallegeDetailDialogHolder {
|
|||
Bundle bundle = new Bundle();
|
||||
bundle.putString(ChallengeDetailActivity.CHALLENGE_ID, challenge.id);
|
||||
|
||||
Intent intent = new Intent(HabiticaApplication.currentActivity, ChallengeDetailActivity.class);
|
||||
Intent intent = new Intent(context, ChallengeDetailActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
//intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
context.startActivity(intent);
|
||||
|
|
@ -308,7 +307,7 @@ public class ChallegeDetailDialogHolder {
|
|||
void leaveChallenge() {
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(context.getString(R.string.challenge_leave_title))
|
||||
.setMessage(String.format(context.getString(R.string.challenge_leave_text), challenge.name))
|
||||
.setMessage(context.getString(R.string.challenge_leave_text, challenge.name))
|
||||
.setPositiveButton(context.getString(R.string.yes), (dialog, which) ->
|
||||
|
||||
showRemoveTasksDialog(keepTasks -> this.apiClient.leaveChallenge(challenge.id, new LeaveChallengeBody(keepTasks))
|
||||
|
|
@ -124,7 +124,7 @@ public class ChallengeListFragment extends BaseMainFragment implements SwipeRefr
|
|||
|
||||
challengeFilterLayout.setVisibility(withFilter?View.VISIBLE:View.GONE);
|
||||
challengeFilterLayout.setClickable(true);
|
||||
challengeFilterLayout.setOnClickListener(view -> ChallegeFilterDialogHolder.showDialog(HabiticaApplication.currentActivity, currentChallengesInView, lastFilterOptions, filterOptions -> {
|
||||
challengeFilterLayout.setOnClickListener(view -> ChallegeFilterDialogHolder.showDialog(getActivity(), currentChallengesInView, lastFilterOptions, filterOptions -> {
|
||||
challengeAdapter.setFilterByGroups(filterOptions);
|
||||
this.lastFilterOptions = filterOptions;
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class ChallengesOverviewFragment extends BaseMainFragment {
|
|||
public void onEvent(ShowChallengeDetailDialogCommand cmd) {
|
||||
Challenge challenge = new Select().from(Challenge.class).where(Condition.column("id").is(cmd.challengeId)).querySingle();
|
||||
|
||||
ChallegeDetailDialogHolder.showDialog(HabiticaApplication.currentActivity, apiClient, user, challenge, challenge1 -> {
|
||||
ChallengeDetailDialogHolder.showDialog(getActivity(), apiClient, user, challenge, challenge1 -> {
|
||||
// challenge joined
|
||||
userChallengesFragment.addItem(challenge1);
|
||||
availableChallengesFragment.updateItem(challenge1);
|
||||
|
|
@ -164,10 +164,10 @@ public class ChallengesOverviewFragment extends BaseMainFragment {
|
|||
Bundle bundle = new Bundle();
|
||||
bundle.putString(ChallengeDetailActivity.CHALLENGE_ID, cmd.challengeId);
|
||||
|
||||
Intent intent = new Intent(HabiticaApplication.currentActivity, ChallengeDetailActivity.class);
|
||||
Intent intent = new Intent(getActivity(), ChallengeDetailActivity.class);
|
||||
intent.putExtras(bundle);
|
||||
//intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
HabiticaApplication.currentActivity.startActivity(intent);
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
|
||||
public boolean onHandleBackPressed() {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class PartyFragment extends BaseMainFragment {
|
|||
PartyFragment.this.activity.supportInvalidateOptionsMenu();
|
||||
|
||||
if (group != null && group.quest != null && group.quest.key != null && !group.quest.key.isEmpty()) {
|
||||
contentCache.GetQuestContent(group.quest.key, content -> {
|
||||
contentCache.getQuestContent(group.quest.key, content -> {
|
||||
if (groupInformationFragment != null) {
|
||||
groupInformationFragment.setQuestContent(content);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import android.annotation.TargetApi;
|
|||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
|
@ -13,13 +15,10 @@ import android.widget.ImageView;
|
|||
public class ViewHelper {
|
||||
|
||||
public static void SetBackgroundTint(Button b, int tint) {
|
||||
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{tint});
|
||||
|
||||
if (b instanceof AppCompatButton) {
|
||||
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{tint});
|
||||
AppCompatButton compatButton = (AppCompatButton) b;
|
||||
|
||||
compatButton.setSupportBackgroundTintList(csl);
|
||||
|
||||
ViewCompat.setBackgroundTintList(compatButton, csl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ public class ViewHelper {
|
|||
}
|
||||
|
||||
@TargetApi(21)
|
||||
public static void SetBackgroundTintV21(Button b, int tint) {
|
||||
private static void SetBackgroundTintV21(Button b, int tint) {
|
||||
|
||||
ColorStateList csl = new ColorStateList(new int[][]{new int[0]}, new int[]{tint});
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ public class ViewHelper {
|
|||
v.getBackground().setColorFilter(tint, PorterDuff.Mode.SRC_OVER);
|
||||
}
|
||||
|
||||
public static void SetBackgroundTint(CheckBox c, int tint) {
|
||||
static void SetBackgroundTint(CheckBox c, int tint) {
|
||||
if (c != null) {
|
||||
c.setBackgroundColor(tint);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.magicmicky.habitrpgwrapper.lib.api;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.habitrpg.android.habitica.ErrorResponse;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.AchievementResult;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.Challenge;
|
||||
|
|
@ -28,10 +30,7 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.ItemData;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.TaskList;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -86,15 +85,15 @@ public interface ApiClient {
|
|||
|
||||
Observable<ArrayList<String>> postTaskNewPosition(String id, String position);
|
||||
|
||||
Observable<Task> scoreChecklistItem(String taskId, String itemId);
|
||||
Observable<Task> scoreChecklistItem(String taskId, String itemId);
|
||||
|
||||
Observable<Task> createItem(Task item);
|
||||
|
||||
Observable<List<Task>> createTasks(List<Task> tasks);
|
||||
|
||||
Observable<Task> updateTask(String id, Task item);
|
||||
Observable<Task> updateTask(String id, Task item);
|
||||
|
||||
Observable<Void> deleteTask( String id);
|
||||
Observable<Void> deleteTask(String id);
|
||||
|
||||
|
||||
Observable<Tag> createTag(Tag tag);
|
||||
|
|
@ -112,9 +111,9 @@ public interface ApiClient {
|
|||
|
||||
Observable<HabitRPGUser> revive();
|
||||
|
||||
Observable<SkillResponse> useSkill( String skillName, String targetType, String targetId);
|
||||
Observable<SkillResponse> useSkill(String skillName, String targetType, String targetId);
|
||||
|
||||
Observable<SkillResponse> useSkill( String skillName, String targetType);
|
||||
Observable<SkillResponse> useSkill(String skillName, String targetType);
|
||||
|
||||
Observable<HabitRPGUser> changeClass();
|
||||
|
||||
|
|
@ -130,30 +129,30 @@ public interface ApiClient {
|
|||
|
||||
Observable<Group> getGroup(String groupId);
|
||||
|
||||
Observable<Void> updateGroup( String id, Group item);
|
||||
Observable<Void> updateGroup(String id, Group item);
|
||||
|
||||
Observable<List<ChatMessage>> listGroupChat( String groupId);
|
||||
Observable<List<ChatMessage>> listGroupChat(String groupId);
|
||||
|
||||
Observable<Group> joinGroup(String groupId);
|
||||
|
||||
Observable<Void> leaveGroup( String groupId);
|
||||
Observable<Void> leaveGroup(String groupId);
|
||||
|
||||
Observable<PostChatMessageResult> postGroupChat( String groupId, HashMap<String, String> message);
|
||||
Observable<PostChatMessageResult> postGroupChat(String groupId, Map<String, String> message);
|
||||
|
||||
Observable<Void> deleteMessage( String groupId, String messageId);
|
||||
Observable<Void> deleteMessage(String groupId, String messageId);
|
||||
|
||||
Observable<List<HabitRPGUser>> getGroupMembers( String groupId, Boolean includeAllPublicFields);
|
||||
Observable<List<HabitRPGUser>> getGroupMembers(String groupId, Boolean includeAllPublicFields);
|
||||
|
||||
Observable<List<HabitRPGUser>> getGroupMembers( String groupId, Boolean includeAllPublicFields, String lastId);
|
||||
Observable<List<HabitRPGUser>> getGroupMembers(String groupId, Boolean includeAllPublicFields, String lastId);
|
||||
|
||||
// Like returns the full chat list
|
||||
Observable<ChatMessage> likeMessage( String groupId, String mid);
|
||||
Observable<ChatMessage> likeMessage(String groupId, String mid);
|
||||
|
||||
Observable<Void> flagMessage(String groupId, String mid);
|
||||
Observable<Void> flagMessage(String groupId, String mid);
|
||||
|
||||
Observable<Void> seenMessages(String groupId);
|
||||
|
||||
Observable<Void> inviteToGroup( String groupId, Map<String, Object> inviteData);
|
||||
Observable<Void> inviteToGroup(String groupId, Map<String, Object> inviteData);
|
||||
|
||||
Observable<Void> rejectGroupInvite(String groupId);
|
||||
|
||||
|
|
@ -161,13 +160,13 @@ public interface ApiClient {
|
|||
|
||||
Observable<Void> rejectQuest(String groupId);
|
||||
|
||||
Observable<Void> cancelQuest( String groupId);
|
||||
Observable<Void> cancelQuest(String groupId);
|
||||
|
||||
Observable<Quest> forceStartQuest( String groupId, Group group);
|
||||
Observable<Quest> forceStartQuest(String groupId, Group group);
|
||||
|
||||
Observable<Quest> inviteToQuest( String groupId,String questKey);
|
||||
Observable<Quest> inviteToQuest(String groupId,String questKey);
|
||||
|
||||
Observable<Quest> abortQuest( String groupId);
|
||||
Observable<Quest> abortQuest(String groupId);
|
||||
|
||||
Observable<Void> leaveQuest(String groupId);
|
||||
|
||||
|
|
@ -176,16 +175,16 @@ public interface ApiClient {
|
|||
Observable<HabitRPGUser> changeCustomDayStart(Map<String, Object> updateObject);
|
||||
|
||||
//Members URL
|
||||
Observable<HabitRPGUser> GetMember(String memberId);
|
||||
Observable<HabitRPGUser> getMember(String memberId);
|
||||
|
||||
Observable<AchievementResult> GetMemberAchievements(String memberId);
|
||||
Observable<AchievementResult> getMemberAchievements(String memberId);
|
||||
|
||||
Observable<PostChatMessageResult> postPrivateMessage(HashMap<String, String> messageDetails);
|
||||
Observable<PostChatMessageResult> postPrivateMessage(Map<String, String> messageDetails);
|
||||
|
||||
Observable<Shop> fetchShopInventory(String identifier);
|
||||
|
||||
//Push notifications
|
||||
Observable<Void> addPushDevice( Map<String, String> pushDeviceData);
|
||||
Observable<Void> addPushDevice(Map<String, String> pushDeviceData);
|
||||
|
||||
Observable<Void> deletePushDevice(String regId);
|
||||
|
||||
|
|
@ -193,7 +192,7 @@ public interface ApiClient {
|
|||
|
||||
Observable<ArrayList<Challenge>> getUserChallenges();
|
||||
|
||||
Observable<TaskList> getChallengeTasks( String challengeId);
|
||||
Observable<TaskList> getChallengeTasks(String challengeId);
|
||||
|
||||
Observable<Challenge> getChallenge(String challengeId);
|
||||
|
||||
|
|
@ -214,7 +213,7 @@ public interface ApiClient {
|
|||
|
||||
boolean hasAuthenticationKeys();
|
||||
|
||||
Observable<HabitRPGUser> retrieveUser(boolean b);
|
||||
Observable<HabitRPGUser> retrieveUser(boolean withTasks);
|
||||
|
||||
<T> Observable.Transformer<HabitResponse<T>, T> configureApiCallObserver();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
|||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.TaskList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -194,7 +193,7 @@ public interface ApiService {
|
|||
Observable<HabitResponse<Void>> leaveGroup(@Path("gid") String groupId);
|
||||
|
||||
@POST("groups/{gid}/chat")
|
||||
Observable<HabitResponse<PostChatMessageResult>> postGroupChat(@Path("gid") String groupId, @Body HashMap<String, String> message);
|
||||
Observable<HabitResponse<PostChatMessageResult>> postGroupChat(@Path("gid") String groupId, @Body Map<String, String> message);
|
||||
|
||||
@DELETE("groups/{gid}/chat/{messageId}")
|
||||
Observable<HabitResponse<Void>> deleteMessage(@Path("gid") String groupId, @Path("messageId") String messageId);
|
||||
|
|
@ -253,13 +252,13 @@ public interface ApiService {
|
|||
|
||||
//Members URL
|
||||
@GET("members/{mid}")
|
||||
Observable<HabitResponse<HabitRPGUser>> GetMember(@Path("mid") String memberId);
|
||||
Observable<HabitResponse<HabitRPGUser>> getMember(@Path("mid") String memberId);
|
||||
|
||||
@GET("members/{mid}/achievements")
|
||||
Observable<HabitResponse<AchievementResult>> GetMemberAchievements(@Path("mid") String memberId);
|
||||
Observable<HabitResponse<AchievementResult>> getMemberAchievements(@Path("mid") String memberId);
|
||||
|
||||
@POST("members/send-private-message")
|
||||
Observable<HabitResponse<PostChatMessageResult>> postPrivateMessage(@Body HashMap<String, String> messageDetails);
|
||||
Observable<HabitResponse<PostChatMessageResult>> postPrivateMessage(@Body Map<String, String> messageDetails);
|
||||
|
||||
@GET("shops/{identifier}")
|
||||
Observable<HabitResponse<Shop>> fetchShopInventory(@Path("identifier") String identifier);
|
||||
|
|
|
|||
|
|
@ -10,21 +10,22 @@ public class Server {
|
|||
this(addr, true);
|
||||
}
|
||||
|
||||
public Server(String addr, boolean attachSuffix) {
|
||||
private Server(String addr, boolean attachSuffix) {
|
||||
if (attachSuffix) {
|
||||
if (addr.endsWith("/api/v3") || addr.endsWith("/api/v3/"))
|
||||
if (addr.endsWith("/api/v3") || addr.endsWith("/api/v3/")) {
|
||||
this.addr = addr;
|
||||
else if (addr.endsWith("/"))
|
||||
} else if (addr.endsWith("/")) {
|
||||
this.addr = addr + "api/v3/";
|
||||
else
|
||||
} else {
|
||||
this.addr = addr + "/api/v3/";
|
||||
}
|
||||
} else {
|
||||
this.addr = addr;
|
||||
}
|
||||
}
|
||||
|
||||
public Server(Server s) {
|
||||
this.addr = s.toString();
|
||||
public Server(Server server) {
|
||||
this.addr = server.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -49,8 +49,12 @@ public class Group extends BaseModel {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = (Group) o;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ public class Items extends BaseModel {
|
|||
HashMap<String, Integer> pets;
|
||||
HashMap<String, Boolean> mounts;
|
||||
@Column
|
||||
private String currentMount, currentPet;
|
||||
private String currentMount;
|
||||
@Column
|
||||
private String currentPet;
|
||||
@Column
|
||||
private int lastDrop_count;
|
||||
@Column
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import com.raizlabs.android.dbflow.structure.BaseModel;
|
|||
*/
|
||||
@Table(databaseName = HabitDatabase.NAME)
|
||||
public class ItemData extends BaseModel {
|
||||
public static final String UNIQUE_IDENTIFIER = "key";
|
||||
|
||||
@Column
|
||||
public double value;
|
||||
@Column
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public class PopupNotificationsManagerTest {
|
|||
public String username;
|
||||
public final String password = "password";
|
||||
private Context context;
|
||||
private PopupNotificationsManager popupNotificationsManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
|
@ -53,14 +54,14 @@ public class PopupNotificationsManagerTest {
|
|||
BuildConfig.PORT,
|
||||
"",
|
||||
"");
|
||||
popupNotificationsManager =new PopupNotificationsManager(context);
|
||||
|
||||
apiClient = new ApiClientImpl(ApiClientImpl.createGsonFactory(), hostConfig, new EmptyCrashlyticsProxy(), context);
|
||||
apiClient = new ApiClientImpl(ApiClientImpl.createGsonFactory(), hostConfig, new EmptyCrashlyticsProxy(), popupNotificationsManager, context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void itDoesNothingWhenNotificationsListIsEmpty() {
|
||||
List<Notification> notifications = new ArrayList<>();
|
||||
PopupNotificationsManager popupNotificationsManager = PopupNotificationsManager.getInstance(apiClient, context);
|
||||
popupNotificationsManager.showNotificationDialog(notifications);
|
||||
|
||||
AlertDialog alert =
|
||||
|
|
|
|||
Loading…
Reference in a new issue