mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Fixed merge conflicts and updated to development version
This commit is contained in:
commit
3f2567f317
26 changed files with 261 additions and 172 deletions
24
.travis.yml
Normal file
24
.travis.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
language: android
|
||||
android:
|
||||
components:
|
||||
# Uncomment the lines below if you want to
|
||||
# use the latest revision of Android SDK Tools
|
||||
# - platform-tools
|
||||
# - tools
|
||||
|
||||
# The BuildTools version used by your project
|
||||
- build-tools-23.0.1
|
||||
|
||||
# The SDK version used to compile your project
|
||||
- android-23
|
||||
|
||||
# Additional components
|
||||
- extra-google-google_play_services
|
||||
- extra-google-m2repository
|
||||
- extra-android-m2repository
|
||||
|
||||
# Specify at least one system image,
|
||||
# if you need to run emulator(s) during your tests
|
||||
#- sys-img-armeabi-v7a-android-19
|
||||
#- sys-img-x86-android-17
|
||||
script: ./gradlew assembleDebug
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'com.android.databinding'
|
||||
apply plugin: 'aar-link-sources'
|
||||
apply plugin: 'io.fabric'
|
||||
|
||||
buildscript {
|
||||
|
|
@ -86,6 +85,9 @@ dependencies {
|
|||
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
|
||||
//Material Dialogs
|
||||
compile('com.github.afollestad.material-dialogs:core:0.8.5.0@aar')
|
||||
|
||||
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
||||
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
6
Habitica/res/drawable-v21/btn_habit_background.xml
Normal file
6
Habitica/res/drawable-v21/btn_habit_background.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:colorControlHighlight">
|
||||
<item android:id="@android:id/mask"
|
||||
android:drawable="@color/brand" />
|
||||
</ripple>
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#33000000" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:state_focused="true" >
|
||||
<item android:state_focused="true">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#33000000" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
|||
|
|
@ -25,26 +25,40 @@
|
|||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:id="@+id/btnLayout">
|
||||
<Button
|
||||
android:id="@+id/btnPlus"
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:visibility="@{habit.up ? View.VISIBLE : View.GONE}"
|
||||
android:text="+"
|
||||
android:background="@{habit.down ? @drawable/btn_habit_background : @drawable/btn_habit_single_background}"
|
||||
app:backgroundColor="@{habit.getLightTaskColor}"
|
||||
style="@style/HabitButton" />
|
||||
<Button
|
||||
android:id="@+id/btnMinus"
|
||||
android:layout_weight="1">
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:backgroundColor="@{habit.getLightTaskColor}"/>
|
||||
<Button
|
||||
android:id="@+id/btnPlus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="+"
|
||||
android:background="@drawable/btn_habit_background"
|
||||
style="@style/HabitButton" />
|
||||
</FrameLayout>
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:visibility="@{habit.down ? View.VISIBLE : View.GONE}"
|
||||
app:backgroundColor="@{habit.up ? habit.getMediumTaskColor : habit.getLightTaskColor}"
|
||||
android:text="-"
|
||||
android:background="@{habit.up ? @drawable/btn_habit_background : @drawable/btn_habit_single_background}"
|
||||
style="@style/HabitButton"/>
|
||||
android:layout_weight="1">
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:backgroundColor="@{habit.up ? habit.getMediumTaskColor : habit.getLightTaskColor}"/>
|
||||
<Button
|
||||
android:id="@+id/btnMinus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="-"
|
||||
android:background="@drawable/btn_habit_background"
|
||||
style="@style/HabitButton"/>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
|||
|
|
@ -56,13 +56,11 @@ public class APIHelper implements ErrorHandler, Profiler {
|
|||
// I think we don't need the APIHelper anymore we could just use ApiService
|
||||
public final ApiService apiService;
|
||||
private final InAppPurchasesApiService inAppPurchasesService;
|
||||
private Context mContext;
|
||||
private HostConfig cfg;
|
||||
|
||||
//private OnHabitsAPIResult mResultListener;
|
||||
//private HostConfig mConfig;
|
||||
public APIHelper(Context c, final HostConfig cfg) {
|
||||
this.mContext = c;
|
||||
public APIHelper(final HostConfig cfg) {
|
||||
this.cfg = cfg;
|
||||
|
||||
RequestInterceptor requestInterceptor = new RequestInterceptor() {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.database.DatabaseErrorHandler;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
|
|
@ -14,11 +15,10 @@ import android.support.annotation.Nullable;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.facebook.FacebookSdk;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
import com.raizlabs.android.dbflow.config.FlowManager;
|
||||
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
import org.solovyev.android.checkout.Billing;
|
||||
import org.solovyev.android.checkout.Cache;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
|
|
@ -48,6 +48,11 @@ public class HabiticaApplication extends Application {
|
|||
|
||||
Instance = this;
|
||||
|
||||
// LeakCanary 1.3.1 has problems on Marshmallow; can remove check once updated with fixes
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
LeakCanary.install(this);
|
||||
}
|
||||
|
||||
createBillingAndCheckout();
|
||||
|
||||
FlowManager.init(this);
|
||||
|
|
@ -90,7 +95,7 @@ public class HabiticaApplication extends Application {
|
|||
|
||||
@Override
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
|
||||
currentActivity = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.Set;
|
|||
public class HabiticaPurchaseVerifier extends BasePurchaseVerifier {
|
||||
|
||||
private Set<String> purchasedOrderList = new HashSet<>();
|
||||
static String PURCHASED_PRODUCTS_KEY = "PURCHASED_PRODUCTS";
|
||||
private static final String PURCHASED_PRODUCTS_KEY = "PURCHASED_PRODUCTS";
|
||||
private SharedPreferences preferences;
|
||||
|
||||
public HabiticaPurchaseVerifier(Context context) {
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class LoginActivity extends AppCompatActivity
|
|||
if(hc ==null) {
|
||||
hc = new HostConfig(apiAddress, "80", "", "");
|
||||
}
|
||||
mApiHelper = new APIHelper(this,hc);
|
||||
mApiHelper = new APIHelper(hc);
|
||||
|
||||
this.isRegistering = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import android.view.View;
|
|||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.core.CrashlyticsCore;
|
||||
|
|
@ -37,6 +37,7 @@ import com.habitrpg.android.habitica.prefs.PrefsActivity;
|
|||
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel;
|
||||
import com.habitrpg.android.habitica.ui.MainDrawerBuilder;
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment;
|
||||
import com.habitrpg.android.habitica.ui.fragments.GemsPurchaseFragment;
|
||||
import com.habitrpg.android.habitica.userpicture.UserPicture;
|
||||
import com.habitrpg.android.habitica.userpicture.UserPictureRunnable;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
|
|
@ -59,9 +60,13 @@ import com.raizlabs.android.dbflow.sql.language.Delete;
|
|||
import com.raizlabs.android.dbflow.sql.language.From;
|
||||
import com.raizlabs.android.dbflow.sql.language.Select;
|
||||
import com.raizlabs.android.dbflow.sql.language.Where;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import org.solovyev.android.checkout.ActivityCheckout;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
import retrofit.Callback;
|
||||
import retrofit.RetrofitError;
|
||||
import retrofit.client.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
|
@ -80,7 +85,9 @@ import retrofit.Callback;
|
|||
import retrofit.RetrofitError;
|
||||
import retrofit.client.Response;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements HabitRPGUserCallback.OnUserReceived, TaskScoringCallback.OnTaskScored {
|
||||
public class MainActivity extends AppCompatActivity implements HabitRPGUserCallback.OnUserReceived,
|
||||
TaskScoringCallback.OnTaskScored,
|
||||
GemsPurchaseFragment.Listener {
|
||||
|
||||
public enum SnackbarDisplayType {
|
||||
NORMAL, FAILURE, FAILURE_BLUE, DROP
|
||||
|
|
@ -113,7 +120,7 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
|
|||
private MaterialDialog faintDialog;
|
||||
|
||||
// Checkout needs to be in the Activity..
|
||||
public static ActivityCheckout checkout = null;
|
||||
public ActivityCheckout checkout = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
@ -133,7 +140,7 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
|
|||
if(!HabiticaApplication.checkUserAuthentication(this, hostConfig))
|
||||
return;
|
||||
|
||||
HabiticaApplication.ApiHelper = this.mAPIHelper = new APIHelper(this, hostConfig);
|
||||
HabiticaApplication.ApiHelper = this.mAPIHelper = new APIHelper(hostConfig);
|
||||
|
||||
new Select().from(HabitRPGUser.class).where(Condition.column("id").eq(hostConfig.getUser())).async().querySingle(userTransactionListener);
|
||||
|
||||
|
|
@ -170,6 +177,10 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
|
|||
mAPIHelper.retrieveUser(new HabitRPGUserCallback(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityCheckout getActivityCheckout() {
|
||||
return checkout;
|
||||
}
|
||||
|
||||
private void saveLoginInformation() {
|
||||
HabiticaApplication.User = user;
|
||||
|
|
@ -587,13 +598,23 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
|
|||
@Override
|
||||
public void onTaskDataReceived(TaskDirectionData data, Task task) {
|
||||
if (task.type.equals("reward")) {
|
||||
|
||||
showSnackbar(task.getText() + " successfully purchased!");
|
||||
|
||||
} else {
|
||||
notifyUser(data.getExp(), data.getHp(), data.getGp(), data.getLvl(), data.getDelta());
|
||||
if (data.get_tmp() != null) {
|
||||
if (data.get_tmp().getDrop() != null) {
|
||||
this.showSnackbar(data.get_tmp().getDrop().getDialog(), MainActivity.SnackbarDisplayType.DROP);
|
||||
}
|
||||
|
||||
if(user != null){
|
||||
notifyUser(data.getExp(), data.getHp(), data.getGp(), data.getLvl(), data.getDelta());
|
||||
}
|
||||
|
||||
showSnackBarForDataReceived(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void showSnackBarForDataReceived(TaskDirectionData data) {
|
||||
if (data.get_tmp() != null) {
|
||||
if (data.get_tmp().getDrop() != null) {
|
||||
this.showSnackbar(data.get_tmp().getDrop().getDialog(), SnackbarDisplayType.DROP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -716,9 +737,8 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
|
|||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if(keyCode == KeyEvent.KEYCODE_MENU){
|
||||
if(keyCode == KeyEvent.KEYCODE_MENU && drawer != null){
|
||||
drawer.openDrawer();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,10 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
|
|||
if (taskId != null) {
|
||||
Task task = new Select().from(Task.class).byIds(taskId).querySingle();
|
||||
this.task = task;
|
||||
populate(task);
|
||||
if(task != null){
|
||||
populate(task);
|
||||
}
|
||||
|
||||
setTitle(task);
|
||||
|
||||
btnDelete.setEnabled(true);
|
||||
|
|
@ -435,7 +438,13 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
|
|||
break;
|
||||
|
||||
case "reward": {
|
||||
task.setValue(Double.parseDouble(taskValue.getText().toString()));
|
||||
String value = taskValue.getText().toString();
|
||||
if(!value.isEmpty()){
|
||||
task.setValue(Double.parseDouble(value));
|
||||
}else{
|
||||
task.setValue(0.0d);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,8 +64,6 @@ public class AvatarWithBarsViewModel implements View.OnClickListener {
|
|||
setValueBar(xpBar, 1, 1, context.getString(R.string.XP_default), R.color.xpColor, R.drawable.ic_header_exp);
|
||||
setValueBar(mpBar, 100, 100, context.getString(R.string.MP_default), R.color.mpColor, R.drawable.ic_header_magic);
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
gemsText.setClickable(true);
|
||||
gemsText.setOnClickListener(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ import de.greenrobot.event.EventBus;
|
|||
* Created by Negue on 20.08.2015.
|
||||
*/
|
||||
public class ChatRecyclerViewAdapter extends RecyclerView.Adapter<ChatRecyclerViewAdapter.ChatRecyclerViewHolder> {
|
||||
static final int TYPE_DANIEL = 0;
|
||||
static final int TYPE_NEW_MESSAGE = 1;
|
||||
static final int TYPE_MESSAGE = 2;
|
||||
private static final int TYPE_DANIEL = 0;
|
||||
private static final int TYPE_NEW_MESSAGE = 1;
|
||||
private static final int TYPE_MESSAGE = 2;
|
||||
|
||||
private List<ChatMessage> messages;
|
||||
private Context viewContext;
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
|
|||
Context context;
|
||||
public int dailyResetOffset;
|
||||
|
||||
static final int TYPE_HEADER = 0;
|
||||
static final int TYPE_CELL = 1;
|
||||
private static final int TYPE_HEADER = 0;
|
||||
private static final int TYPE_CELL = 1;
|
||||
private RecyclerView.Adapter<ViewHolder> parentAdapter;
|
||||
private TagsHelper tagsHelper;
|
||||
private IAdditionalEntries additionalEntries;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class SkillTasksRecyclerViewAdapter extends RecyclerView.Adapter<SkillTas
|
|||
private ObservableArrayList<Task> observableContent;
|
||||
SkillTasksActivity activity;
|
||||
|
||||
static final int TYPE_CELL = 1;
|
||||
private static final int TYPE_CELL = 1;
|
||||
private RecyclerView.Adapter<ViewHolder> parentAdapter;
|
||||
|
||||
public SkillTasksRecyclerViewAdapter(String taskType, SkillTasksActivity activity) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import com.habitrpg.android.habitica.HabiticaApplication;
|
||||
import com.habitrpg.android.habitica.MainActivity;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.BoughtGemsEvent;
|
||||
import com.habitrpg.android.habitica.ui.helpers.ViewHelper;
|
||||
|
||||
import de.greenrobot.event.EventBus;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import org.solovyev.android.checkout.ActivityCheckout;
|
||||
import org.solovyev.android.checkout.BillingRequests;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
import org.solovyev.android.checkout.ProductTypes;
|
||||
|
|
@ -30,13 +33,22 @@ import io.fabric.sdk.android.Fabric;
|
|||
*/
|
||||
public class GemsPurchaseFragment extends BaseFragment {
|
||||
|
||||
static final int GEMS_TO_ADD = 21;
|
||||
private static final int GEMS_TO_ADD = 21;
|
||||
|
||||
private Listener listener;
|
||||
|
||||
private BillingRequests billingRequests;
|
||||
|
||||
@Bind(R.id.btn_purchase_gems)
|
||||
Button btnPurchaseGems;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
listener = (Listener) context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
|
@ -50,9 +62,11 @@ public class GemsPurchaseFragment extends BaseFragment {
|
|||
btnPurchaseGems.setEnabled(false);
|
||||
ViewHelper.SetBackgroundTint(btnPurchaseGems, container.getResources().getColor(R.color.brand));
|
||||
|
||||
MainActivity.checkout.destroyPurchaseFlow();
|
||||
final ActivityCheckout checkout = listener.getActivityCheckout();
|
||||
|
||||
MainActivity.checkout.createPurchaseFlow(new RequestListener<Purchase>() {
|
||||
checkout.destroyPurchaseFlow();
|
||||
|
||||
checkout.createPurchaseFlow(new RequestListener<Purchase>() {
|
||||
@Override
|
||||
public void onSuccess(Purchase purchase) {
|
||||
if(purchase.sku.equals(HabiticaApplication.Purchase20Gems)){
|
||||
|
|
@ -77,7 +91,7 @@ public class GemsPurchaseFragment extends BaseFragment {
|
|||
});
|
||||
|
||||
|
||||
MainActivity.checkout.whenReady(new Checkout.Listener() {
|
||||
checkout.whenReady(new Checkout.Listener() {
|
||||
@Override
|
||||
public void onReady(final BillingRequests billingRequests) {
|
||||
GemsPurchaseFragment.this.billingRequests = billingRequests;
|
||||
|
|
@ -132,7 +146,8 @@ public class GemsPurchaseFragment extends BaseFragment {
|
|||
public void onSuccess(Boolean aBoolean) {
|
||||
if (!aBoolean) {
|
||||
// no current product exist
|
||||
billingRequests.purchase(ProductTypes.IN_APP, HabiticaApplication.Purchase20Gems, null, MainActivity.checkout.getPurchaseFlow());
|
||||
final ActivityCheckout checkout = listener.getActivityCheckout();
|
||||
billingRequests.purchase(ProductTypes.IN_APP, HabiticaApplication.Purchase20Gems, null, checkout.getPurchaseFlow());
|
||||
}
|
||||
else{
|
||||
checkIfPendingPurchases();
|
||||
|
|
@ -157,4 +172,7 @@ public class GemsPurchaseFragment extends BaseFragment {
|
|||
|
||||
|
||||
|
||||
public interface Listener {
|
||||
ActivityCheckout getActivityCheckout();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ import retrofit.client.Response;
|
|||
|
||||
public class TasksFragment extends BaseFragment implements OnCheckedChangeListener {
|
||||
|
||||
static final int TASK_CREATED_RESULT = 1;
|
||||
static final int TASK_UPDATED_RESULT = 2;
|
||||
private static final int TASK_CREATED_RESULT = 1;
|
||||
private static final int TASK_UPDATED_RESULT = 2;
|
||||
|
||||
public ViewPager viewPager;
|
||||
Drawer filterDrawer;
|
||||
|
|
@ -239,52 +239,52 @@ public class TasksFragment extends BaseFragment implements OnCheckedChangeListen
|
|||
public void GetAdditionalEntries(final IReceiveNewEntries callBack) {
|
||||
|
||||
// request buyable gear
|
||||
mAPIHelper.apiService.getInventoryBuyableGear(new Callback<List<ItemData>>() {
|
||||
@Override
|
||||
public void success(List<ItemData> itemDatas, Response response) {
|
||||
|
||||
// get itemdata list
|
||||
ArrayList<String> itemKeys = new ArrayList<String>();
|
||||
for (ItemData item : itemDatas) {
|
||||
itemKeys.add(item.key);
|
||||
}
|
||||
itemKeys.add("potion");
|
||||
|
||||
contentCache.GetItemDataList(itemKeys, new ContentCache.GotContentEntryCallback<List<ItemData>>() {
|
||||
@Override
|
||||
public void GotObject(List<ItemData> obj) {
|
||||
ArrayList<Task> buyableItems = new ArrayList<Task>();
|
||||
|
||||
for (ItemData item : obj) {
|
||||
Task reward = new Task();
|
||||
reward.text = item.text;
|
||||
reward.notes = item.notes;
|
||||
reward.value = item.value;
|
||||
reward.setType("reward");
|
||||
reward.specialTag = "item";
|
||||
reward.setId(item.key);
|
||||
|
||||
buyableItems.add(reward);
|
||||
}
|
||||
|
||||
callBack.GotAdditionalItems(buyableItems);
|
||||
if(mAPIHelper != null){
|
||||
mAPIHelper.apiService.getInventoryBuyableGear(new Callback<List<ItemData>>() {
|
||||
@Override
|
||||
public void success(List<ItemData> itemDatas, Response response) {
|
||||
|
||||
// get itemdata list
|
||||
ArrayList<String> itemKeys = new ArrayList<String>();
|
||||
for (ItemData item : itemDatas) {
|
||||
itemKeys.add(item.key);
|
||||
}
|
||||
});
|
||||
itemKeys.add("potion");
|
||||
|
||||
contentCache.GetItemDataList(itemKeys, new ContentCache.GotContentEntryCallback<List<ItemData>>() {
|
||||
@Override
|
||||
public void GotObject(List<ItemData> obj) {
|
||||
ArrayList<Task> buyableItems = new ArrayList<Task>();
|
||||
|
||||
for (ItemData item : obj) {
|
||||
Task reward = new Task();
|
||||
reward.text = item.text;
|
||||
reward.notes = item.notes;
|
||||
reward.value = item.value;
|
||||
reward.setType("reward");
|
||||
reward.specialTag = "item";
|
||||
reward.setId(item.key);
|
||||
|
||||
buyableItems.add(reward);
|
||||
}
|
||||
|
||||
callBack.GotAdditionalItems(buyableItems);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
fragment = TaskRecyclerViewFragment.newInstance(adapter, Task.TYPE_REWARD);
|
||||
break;
|
||||
default:
|
||||
|
|
@ -370,31 +370,31 @@ public class TasksFragment extends BaseFragment implements OnCheckedChangeListen
|
|||
|
||||
// endregion
|
||||
|
||||
|
||||
|
||||
//region Events
|
||||
|
||||
public void onEvent(final CreateTagCommand event) {
|
||||
final Tag t = new Tag();
|
||||
t.setName(event.tagName);
|
||||
|
||||
mAPIHelper.apiService.createTag(t, new Callback<List<Tag>>() {
|
||||
@Override
|
||||
public void success(List<Tag> tags, Response response) {
|
||||
// Since we get a list of all tags, we just save them all
|
||||
for (Tag onlineTag : tags) {
|
||||
onlineTag.user_id = user.getId();
|
||||
onlineTag.async().save();
|
||||
if (mAPIHelper != null){
|
||||
mAPIHelper.apiService.createTag(t, new Callback<List<Tag>>() {
|
||||
@Override
|
||||
public void success(List<Tag> tags, Response response) {
|
||||
// Since we get a list of all tags, we just save them all
|
||||
for (Tag onlineTag : tags) {
|
||||
onlineTag.user_id = user.getId();
|
||||
onlineTag.async().save();
|
||||
}
|
||||
|
||||
fillTagFilterDrawer(tags);
|
||||
}
|
||||
|
||||
fillTagFilterDrawer(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
activity.showSnackbar("Error: " + error.getMessage(), MainActivity.SnackbarDisplayType.FAILURE);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
activity.showSnackbar("Error: " + error.getMessage(), MainActivity.SnackbarDisplayType.FAILURE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void onEvent(TaskTappedEvent event) {
|
||||
|
|
@ -441,8 +441,6 @@ public class TasksFragment extends BaseFragment implements OnCheckedChangeListen
|
|||
}
|
||||
|
||||
//endregion Events
|
||||
|
||||
|
||||
public void fillTagFilterDrawer(List<Tag> tagList) {
|
||||
filterDrawer.removeAllItems();
|
||||
filterDrawer.addItems(
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
public class UserPicture {
|
||||
|
||||
static Integer width = 140;
|
||||
static Integer height = 147;
|
||||
static Integer compactWidth = 103;
|
||||
static Integer compactHeight = 90;
|
||||
private static final int WIDTH = 140;
|
||||
private static final int HEIGHT = 147;
|
||||
private static final int COMPACT_WIDTH = 103;
|
||||
private static final int COMPACT_HEIGHT = 90;
|
||||
|
||||
private HabitRPGUser user;
|
||||
private ImageView imageView;
|
||||
|
|
@ -38,7 +38,7 @@ public class UserPicture {
|
|||
|
||||
private String currentCacheFileName;
|
||||
|
||||
List layers = new ArrayList();
|
||||
final List<Bitmap> layers = new ArrayList<>();
|
||||
|
||||
public UserPicture(HabitRPGUser user, Context context) {
|
||||
this.user = user;
|
||||
|
|
@ -63,7 +63,7 @@ public class UserPicture {
|
|||
BitmapFactory.Options o = new BitmapFactory.Options();
|
||||
o.inScaled = false;
|
||||
|
||||
Bitmap res = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Bitmap res = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);
|
||||
Canvas myCanvas = new Canvas(res);
|
||||
Integer layerNumber = 0;
|
||||
for (Object layer : this.layers) {
|
||||
|
|
@ -74,7 +74,7 @@ public class UserPicture {
|
|||
layerNumber++;
|
||||
}
|
||||
if (!this.hasPetMount) {
|
||||
res = Bitmap.createBitmap(res, 25, 18, compactWidth, compactHeight);
|
||||
res = Bitmap.createBitmap(res, 25, 18, COMPACT_WIDTH, COMPACT_HEIGHT);
|
||||
}
|
||||
BitmapUtils.saveToFile(currentCacheFileName, res);
|
||||
if (this.imageView != null) {
|
||||
|
|
@ -92,8 +92,7 @@ public class UserPicture {
|
|||
}
|
||||
|
||||
public void setPictureOn(final ImageView imageView) {
|
||||
UserPicture.this.imageView = imageView;
|
||||
|
||||
this.imageView = imageView;
|
||||
List<String> layerNames = UserPicture.this.getLayerNames();
|
||||
|
||||
final Bitmap cache = UserPicture.this.getCachedImage(layerNames);
|
||||
|
|
@ -104,9 +103,12 @@ public class UserPicture {
|
|||
return;
|
||||
}
|
||||
|
||||
// Clear out current image while loading the new one
|
||||
imageView.setImageBitmap(null);
|
||||
Picasso.with(context).cancelRequest(imageView);
|
||||
|
||||
// no => generate it
|
||||
generateImage(layerNames);
|
||||
|
||||
}
|
||||
|
||||
public void setPictureWithRunnable(UserPictureRunnable runnable) {
|
||||
|
|
@ -121,6 +123,10 @@ public class UserPicture {
|
|||
return;
|
||||
}
|
||||
|
||||
// Clear out current image while loading the new one
|
||||
runnable.run(null);
|
||||
|
||||
// no => generate it
|
||||
generateImage(layerNames);
|
||||
}
|
||||
|
||||
|
|
@ -175,8 +181,9 @@ public class UserPicture {
|
|||
private void generateImage(List<String> layerNames) {
|
||||
Integer layerNumber = 0;
|
||||
this.numOfTasks.set(layerNames.size());
|
||||
layers.clear();
|
||||
for (String layer : layerNames) {
|
||||
layers.add(0);
|
||||
layers.add(null);
|
||||
SpriteTarget target = new SpriteTarget(layerNumber, layer);
|
||||
Picasso.with(this.context).load("https://habitica-assets.s3.amazonaws.com/mobileApp/images/" + layer + ".png").into(target);
|
||||
layerNumber = layerNumber + 1;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class UpdateWidgetService extends Service implements HabitRPGUserCallback
|
|||
|
||||
HostConfig hc = PrefsActivity.fromContext(this);
|
||||
if (hc != null && hc.getApi() != null && !hc.getApi().equals("") && hc.getUser() != null && !hc.getUser().equals("")) {
|
||||
this.apiHelper = new APIHelper(this, hc);
|
||||
this.apiHelper = new APIHelper(hc);
|
||||
apiHelper.retrieveUser(new HabitRPGUserCallback(this));
|
||||
for (int widgetId : allWidgetIds) {
|
||||
RemoteViews remoteViews = new RemoteViews(this.getPackageName(), R.layout.simple_widget);
|
||||
|
|
|
|||
|
|
@ -11,20 +11,20 @@ import java.util.HashMap;
|
|||
*/
|
||||
public class ChatMessage {
|
||||
|
||||
static HashMap<Integer, Integer> contributorColorDict;
|
||||
private static final HashMap<Integer, Integer> CONTRIBUTOR_COLOR_DICT;
|
||||
|
||||
static {
|
||||
contributorColorDict = new HashMap<>();
|
||||
contributorColorDict.put(0, R.color.contributor_0);
|
||||
contributorColorDict.put(1, R.color.contributor_1);
|
||||
contributorColorDict.put(2, R.color.contributor_2);
|
||||
contributorColorDict.put(3, R.color.contributor_3);
|
||||
contributorColorDict.put(4, R.color.contributor_4);
|
||||
contributorColorDict.put(5, R.color.contributor_5);
|
||||
contributorColorDict.put(6, R.color.contributor_6);
|
||||
contributorColorDict.put(7, R.color.contributor_7);
|
||||
contributorColorDict.put(8, R.color.contributor_mod);
|
||||
contributorColorDict.put(9, R.color.contributor_staff);
|
||||
CONTRIBUTOR_COLOR_DICT = new HashMap<>();
|
||||
CONTRIBUTOR_COLOR_DICT.put(0, R.color.contributor_0);
|
||||
CONTRIBUTOR_COLOR_DICT.put(1, R.color.contributor_1);
|
||||
CONTRIBUTOR_COLOR_DICT.put(2, R.color.contributor_2);
|
||||
CONTRIBUTOR_COLOR_DICT.put(3, R.color.contributor_3);
|
||||
CONTRIBUTOR_COLOR_DICT.put(4, R.color.contributor_4);
|
||||
CONTRIBUTOR_COLOR_DICT.put(5, R.color.contributor_5);
|
||||
CONTRIBUTOR_COLOR_DICT.put(6, R.color.contributor_6);
|
||||
CONTRIBUTOR_COLOR_DICT.put(7, R.color.contributor_7);
|
||||
CONTRIBUTOR_COLOR_DICT.put(8, R.color.contributor_mod);
|
||||
CONTRIBUTOR_COLOR_DICT.put(9, R.color.contributor_staff);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ public class ChatMessage {
|
|||
|
||||
|
||||
if (contributor != null) {
|
||||
if (contributorColorDict.containsKey(contributor.level)) {
|
||||
rColor = contributorColorDict.get(contributor.level);
|
||||
if (CONTRIBUTOR_COLOR_DICT.containsKey(contributor.level)) {
|
||||
rColor = CONTRIBUTOR_COLOR_DICT.get(contributor.level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ import java.util.concurrent.TimeUnit;
|
|||
@ModelContainer
|
||||
@Table(databaseName = HabitDatabase.NAME)
|
||||
public class Task extends BaseModel {
|
||||
public static String TYPE_HABIT = "habit";
|
||||
public static String TYPE_TODO = "todo";
|
||||
public static String TYPE_DAILY = "daily";
|
||||
public static String TYPE_REWARD = "reward";
|
||||
public static String FREQUENCY_WEEKLY = "weekly";
|
||||
public static String FREQUENCY_DAILY = "daily";
|
||||
public static final String TYPE_HABIT = "habit";
|
||||
public static final String TYPE_TODO = "todo";
|
||||
public static final String TYPE_DAILY = "daily";
|
||||
public static final String TYPE_REWARD = "reward";
|
||||
public static final String FREQUENCY_WEEKLY = "weekly";
|
||||
public static final String FREQUENCY_DAILY = "daily";
|
||||
|
||||
|
||||
@Column
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# Habitica for Android
|
||||
[](https://travis-ci.org/HabitRPG/habitrpg-android)
|
||||
|
||||
[Habitica](https://habitica.com) is an open source habit building program which treats your life like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor. This repository is related to the Android Native Application.
|
||||
|
||||
|
|
@ -9,7 +10,7 @@ It's also on Google Play:
|
|||
src="https://developer.android.com/images/brand/en_generic_rgb_wo_60.png" />
|
||||
</a>
|
||||
|
||||
Having the application installed is a good way to be notified of new releases. Although Watching this
|
||||
Having the application installed is a good way to be notified of new releases. However, clicking "Watch" on this
|
||||
repository will allow GitHub to email you whenever we publish a release.
|
||||
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ If you Watch this repository, GitHub will send you an email every time we publis
|
|||
|
||||
For an introduction to the technologies used and how the software is organized, refer to [Contributing to Habitica](http://habitica.wikia.com/wiki/Contributing_to_Habitica#Coders_.28Web_.26_Mobile.29) - "Coders (Web & Mobile)" section.
|
||||
|
||||
Thank you very much [for all contributors](https://github.com/HabitRPG/habitrpg-android/graphs/contributors)
|
||||
Thank you very much [to all contributors](https://github.com/HabitRPG/habitrpg-android/graphs/contributors).
|
||||
|
||||
#### Steps for contributing to this repository:
|
||||
|
||||
|
|
@ -34,5 +35,5 @@ Thank you very much [for all contributors](https://github.com/HabitRPG/habitrpg-
|
|||
3. Commit your changes: `git commit -am 'Add some feature'`
|
||||
4. Push to the branch: `git push origin my-new-feature`
|
||||
5. Create new Pull Request
|
||||
Don't forget to include your Habitica User ID, so that we can count your contributrion towards your contributor tier
|
||||
* Don't forget to include your Habitica User ID, so that we can count your contributrion towards your contributor tier
|
||||
|
||||
|
|
|
|||
14
build.gradle
14
build.gradle
|
|
@ -3,19 +3,11 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
//Plugin to download sources on a fake maven github repo
|
||||
maven { url 'https://raw.github.com/xujiaao/mvn-repository/master/releases' }
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.3.0'
|
||||
classpath 'com.android.databinding:dataBinder:1.0-rc1'
|
||||
|
||||
//Class path for the plugin to auto download sources
|
||||
classpath 'com.github.xujiaao:aarLinkSources:1.0.0'
|
||||
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
|
||||
|
||||
classpath 'com.android.tools.build:gradle:1.5.0'
|
||||
classpath 'com.android.databinding:dataBinder:1.0-rc4'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
12
gradle/wrapper/gradle-wrapper.properties
vendored
12
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,6 +1,6 @@
|
|||
#Fri Jan 23 10:03:42 CET 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
|
||||
#Wed Dec 16 10:47:35 CST 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
|
||||
|
|
|
|||
10
gradlew
vendored
10
gradlew
vendored
|
|
@ -42,11 +42,6 @@ case "`uname`" in
|
|||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
|
|
@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
|
|||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
|
@ -114,6 +109,7 @@ fi
|
|||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
|
|
|
|||
Loading…
Reference in a new issue