Merge branch 'develop' of https://github.com/HabitRPG/habitrpg-android into develop
Conflicts: Habitica/src/com/habitrpg/android/habitica/ui/fragments/ChatListFragment.java
|
|
@ -31,25 +31,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!--
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Invitations" />
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="list of invitations" />
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
-->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
@ -96,6 +77,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_column="0"
|
||||
android:layout_columnSpan="2"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@{quest.text}" />
|
||||
|
||||
<ImageView
|
||||
|
|
@ -113,24 +95,14 @@
|
|||
android:layout_row="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
android:text='@{"HP: "+ quest.boss.hp}' />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
android:text='@{"Str: "+ quest.boss.str}' />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_column="0"
|
||||
android:layout_columnSpan="2"
|
||||
android:layout_row="2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp">
|
||||
|
||||
<TextView android:layout_margin="5dp"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionNext"
|
||||
android:hint="@string/email_username"
|
||||
android:hint="@string/username"
|
||||
/>
|
||||
|
||||
</TableRow>
|
||||
|
|
@ -71,8 +71,7 @@
|
|||
<TableRow
|
||||
android:id="@+id/email_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="17dp"
|
||||
|
|
@ -111,7 +110,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true"
|
||||
android:imeOptions="actionDone"
|
||||
android:imeOptions="actionNext"
|
||||
android:hint="@string/password"
|
||||
/>
|
||||
</TableRow>
|
||||
|
|
@ -119,8 +118,7 @@
|
|||
<TableRow
|
||||
android:id="@+id/confirm_password_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="17dp"
|
||||
|
|
@ -155,7 +153,7 @@
|
|||
android:id="@+id/login_btn"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/login_btn"
|
||||
android:text="@string/register_btn"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<ProgressBar
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@
|
|||
android:layout_width="25dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_weight="0.06"
|
||||
android:src="@drawable/ic_action_more_vert" />
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
android:id="@+id/action_toggleRegistering"
|
||||
android:orderInCategory="1"
|
||||
app:showAsAction="ifRoom"
|
||||
android:title="@string/register_btn"
|
||||
android:title="@string/login_btn"
|
||||
abc:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
|
|
@ -2,6 +2,6 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.habitrpg.android.habitica.TaskFormActivity">
|
||||
<item android:id="@+id/action_discard_changes" android:title="@string/discard_changes"
|
||||
<item android:id="@+id/action_save_changes" android:title="@string/save_changes"
|
||||
android:orderInCategory="100" app:showAsAction="always" />
|
||||
</menu>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 29 KiB |
|
|
@ -141,7 +141,7 @@
|
|||
<string name="checklist.item.hint">Add item…</string>
|
||||
<string name="title_activity_task_form">Add Task</string>
|
||||
|
||||
<string name="discard_changes">Cancel</string>
|
||||
<string name="save_changes">Save</string>
|
||||
<string name="notes">Notes</string>
|
||||
<string name="text">Text</string>
|
||||
<string name="difficulty">Difficulty</string>
|
||||
|
|
@ -195,4 +195,6 @@
|
|||
<string name="reminder_title">Remember to check off your Dailies!</string>
|
||||
<string name="skill_progress_title">Using Skill</string>
|
||||
<string name="coming_soon">Coming Soon</string>
|
||||
<string name="chat_flag_confirmation">Are you sure you want to report this message for violation?</string>
|
||||
<string name="flag_confirm">Flag Message</string>
|
||||
</resources>
|
||||
|
|
@ -68,6 +68,7 @@ public class APIHelper implements ErrorHandler, Profiler {
|
|||
public void intercept(RequestInterceptor.RequestFacade request) {
|
||||
request.addHeader("x-api-key", cfg.getApi());
|
||||
request.addHeader("x-api-user", cfg.getUser());
|
||||
request.addHeader("x-client", "habitica-android");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -114,8 +114,8 @@ public class LoginActivity extends AppCompatActivity
|
|||
}
|
||||
mApiHelper = new APIHelper(this,hc);
|
||||
|
||||
this.isRegistering = false;
|
||||
}
|
||||
this.isRegistering = true;
|
||||
}
|
||||
|
||||
private void resetLayout() {
|
||||
if (this.isRegistering) {
|
||||
|
|
@ -181,16 +181,20 @@ public class LoginActivity extends AppCompatActivity
|
|||
|
||||
private void toggleRegistering() {
|
||||
this.isRegistering = !this.isRegistering;
|
||||
this.setRegistering(this.isRegistering);
|
||||
}
|
||||
|
||||
private void setRegistering(boolean registering) {
|
||||
MenuItem menuItem = menu.findItem(R.id.action_toggleRegistering);
|
||||
if (this.isRegistering) {
|
||||
this.mLoginNormalBtn.setText(getString(R.string.register_btn));
|
||||
menuItem.setTitle(getString(R.string.login_btn));
|
||||
mUsernameET.setHint(R.string.username);
|
||||
mUsernameET.setHint(R.string.username);
|
||||
mPasswordET.setImeOptions(EditorInfo.IME_ACTION_NEXT);
|
||||
} else {
|
||||
this.mLoginNormalBtn.setText(getString(R.string.login_btn));
|
||||
menuItem.setTitle(getString(R.string.register_btn));
|
||||
mUsernameET.setHint(R.string.email_username);
|
||||
mUsernameET.setHint(R.string.email_username);
|
||||
mPasswordET.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
}
|
||||
this.resetLayout();
|
||||
|
|
|
|||
|
|
@ -455,7 +455,10 @@ public class MainActivity extends AppCompatActivity implements HabitRPGUserCallb
|
|||
}
|
||||
|
||||
public void showSnackbar(String content, SnackbarDisplayType displayType) {
|
||||
Snackbar snackbar = Snackbar.make(floatingMenuWrapper, content, Snackbar.LENGTH_LONG);
|
||||
if (this.isFinishing()) {
|
||||
return;
|
||||
}
|
||||
Snackbar snackbar = Snackbar.make(floatingMenuWrapper, content, Snackbar.LENGTH_LONG);
|
||||
View snackbarView = snackbar.getView();
|
||||
|
||||
if (displayType == SnackbarDisplayType.FAILURE) {
|
||||
|
|
|
|||
|
|
@ -313,9 +313,8 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
|
|||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_discard_changes) {
|
||||
finish();
|
||||
dismissKeyboard();
|
||||
if (id == R.id.action_save_changes) {
|
||||
finishActivitySuccessfuly();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -452,13 +451,15 @@ public class TaskFormActivity extends AppCompatActivity implements AdapterView.O
|
|||
|
||||
@Override
|
||||
public boolean onSupportNavigateUp() {
|
||||
this.finishActivitySuccessfuly();
|
||||
finish();
|
||||
dismissKeyboard();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
this.finishActivitySuccessfuly();
|
||||
finish();
|
||||
dismissKeyboard();
|
||||
}
|
||||
|
||||
private void finishActivitySuccessfuly() {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ 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.CopyChatAsTodoCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.DeleteChatMessageCommand;
|
||||
|
|
@ -190,6 +191,7 @@ public class ChatRecyclerViewAdapter extends RecyclerView.Adapter<ChatRecyclerVi
|
|||
btnToggleInn.setOnClickListener(this);
|
||||
|
||||
ViewHelper.SetBackgroundTint(btnToggleInn, res.getColor(R.color.brand));
|
||||
changeSleepButton(true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -345,6 +347,7 @@ public class ChatRecyclerViewAdapter extends RecyclerView.Adapter<ChatRecyclerVi
|
|||
|
||||
if (v == btnToggleInn) {
|
||||
EventBus.getDefault().post(new ToggleInnCommand());
|
||||
changeSleepButton(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -357,6 +360,14 @@ public class ChatRecyclerViewAdapter extends RecyclerView.Adapter<ChatRecyclerVi
|
|||
textNewMessage.setText("");
|
||||
}
|
||||
|
||||
public void changeSleepButton(boolean startupButton){
|
||||
if(HabiticaApplication.User.getPreferences().getSleep() && startupButton){
|
||||
btnToggleInn.setText("Check Out of Inn");
|
||||
}else{
|
||||
btnToggleInn.setText("Rest in the Inn");
|
||||
}
|
||||
}
|
||||
|
||||
private void toggleLike() {
|
||||
int newCount = currentUserLikedPost ? --likeCount : ++likeCount;
|
||||
currentUserLikedPost = !currentUserLikedPost;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
package com.habitrpg.android.habitica.ui.fragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -14,6 +16,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import com.habitrpg.android.habitica.APIHelper;
|
||||
import com.habitrpg.android.habitica.MainActivity;
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.ToggledInnStateEvent;
|
||||
import com.habitrpg.android.habitica.events.commands.DeleteChatMessageCommand;
|
||||
|
|
@ -47,8 +50,9 @@ public class ChatListFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
private HabitRPGUser user;
|
||||
private String userId;
|
||||
private boolean isTavern;
|
||||
private MainActivity activity;
|
||||
|
||||
public ChatListFragment(Context ctx, String groupId, APIHelper apiHelper, HabitRPGUser user, boolean isTavern) {
|
||||
public ChatListFragment(Context ctx, String groupId, APIHelper apiHelper, HabitRPGUser user, MainActivity activity, boolean isTavern) {
|
||||
|
||||
this.ctx = ctx;
|
||||
this.groupId = groupId;
|
||||
|
|
@ -56,6 +60,7 @@ public class ChatListFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
this.user = user;
|
||||
this.userId = user.getId();
|
||||
this.isTavern = isTavern;
|
||||
this.activity = activity;
|
||||
|
||||
// Receive Events
|
||||
EventBus.getDefault().register(this);
|
||||
|
|
@ -144,32 +149,27 @@ public class ChatListFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void showSnackbar(String msg, boolean negative) {
|
||||
Snackbar snackbar = Snackbar.make(mRecyclerView, msg, Snackbar.LENGTH_LONG);
|
||||
|
||||
if (negative) {
|
||||
View snackbarView = snackbar.getView();
|
||||
|
||||
//change Snackbar's background color;
|
||||
snackbarView.setBackgroundColor(Color.RED);
|
||||
}
|
||||
|
||||
snackbar.show();
|
||||
}
|
||||
|
||||
public void onEvent(final FlagChatMessageCommand cmd) {
|
||||
apiHelper.apiService.flagMessage(cmd.groupId, cmd.chatMessage.id, new Callback<Void>() {
|
||||
@Override
|
||||
public void success(Void aVoid, Response response) {
|
||||
showSnackbar("Flagged message by " + cmd.chatMessage.user, false);
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.chat_flag_confirmation)
|
||||
.setPositiveButton(R.string.flag_confirm, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
apiHelper.apiService.flagMessage(cmd.groupId, cmd.chatMessage.id, new Callback<Void>() {
|
||||
@Override
|
||||
public void success(Void aVoid, Response response) {
|
||||
activity.showSnackbar("Flagged message by " + cmd.chatMessage.user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
showSnackbar("Failed to flag message by " + cmd.chatMessage.user, true);
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void failure(RetrofitError error) {
|
||||
}
|
||||
}); }
|
||||
})
|
||||
.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
public void onEvent(final ToggleLikeMessageCommand cmd) {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class PartyFragment extends BaseFragment {
|
|||
break;
|
||||
}
|
||||
case 1: {
|
||||
fragment = new ChatListFragment(activity, "party", mAPIHelper, user, false);
|
||||
fragment = new ChatListFragment(activity, "party", mAPIHelper, user, activity, false);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public class TavernFragment extends BaseFragment {
|
|||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View v = inflater.inflate(R.layout.fragment_tavern, container, false);
|
||||
|
||||
setFragment(new ChatListFragment(activity, "habitrpg", mAPIHelper, user, true));
|
||||
setFragment(new ChatListFragment(activity, "habitrpg", mAPIHelper, user, activity, true));
|
||||
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||