Skip to content
This repository has been archived by the owner on Dec 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #41 from Longi94/development
Browse files Browse the repository at this point in the history
v2.1.1
  • Loading branch information
Longi94 committed May 1, 2016
2 parents 439fbca + 82af148 commit fe4895a
Show file tree
Hide file tree
Showing 80 changed files with 72 additions and 526 deletions.
6 changes: 2 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ android {
applicationId "com.tlongdev.bktf"
minSdkVersion 14
targetSdkVersion 23
versionCode 42
versionName "2.1.0"
versionCode 43
versionName "2.1.1"

applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File((String) output.outputFile.parent, "bptf-" + versionName + ".apk")
}
}

vectorDrawables.useSupportLibrary = true

Properties keys = new Properties()
if (project.rootProject.file('keys.properties').exists()) {
keys.load(project.rootProject.file('keys.properties').newDataInputStream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ public void update(User user) {

public void setUserMenuItem(MenuItem userMenuItem) {
mUserMenuItem = userMenuItem;
if (mUserMenuItem != null) {
mUserMenuItem.setEnabled(mProfileManager.isSignedIn());
}
}

@Override
Expand Down
48 changes: 7 additions & 41 deletions app/src/main/java/com/tlongdev/bktf/ui/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
Expand Down Expand Up @@ -86,12 +85,6 @@ public class MainActivity extends AppCompatActivity {
*/
private boolean mUserStateChanged = false;

/**
* Listener to be notified when the drawer opens. Mainly for fragments with toolbars so we can
* expand the fragment's toolbar when the drawer opens.
*/
private OnDrawerOpenedListener mDrawerListener;

/**
* Listener for the navigation drawer.
*/
Expand Down Expand Up @@ -259,39 +252,26 @@ private void switchFragment(int position) {
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.setCustomAnimations(R.anim.simple_fade_in, R.anim.simple_fade_out);
Fragment newFragment;

//Initialize fragments and add them is the drawer listener
switch (position) {
case 0:
newFragment = new RecentsFragment();
mDrawerListener = (RecentsFragment) newFragment;
transaction.replace(R.id.container, newFragment);
transaction.replace(R.id.container, new RecentsFragment());
break;
case 1:
newFragment = new UnusualFragment();
mDrawerListener = (UnusualFragment) newFragment;
transaction.replace(R.id.container, newFragment);
transaction.replace(R.id.container, new UnusualFragment());
break;
case 2:
newFragment = UserFragment.newInstance();
mDrawerListener = (UserFragment) newFragment;
transaction.replace(R.id.container, newFragment);
transaction.replace(R.id.container, UserFragment.newInstance());
break;
case 3:
newFragment = new FavoritesFragment();
mDrawerListener = (FavoritesFragment) newFragment;
transaction.replace(R.id.container, newFragment);
transaction.replace(R.id.container, new FavoritesFragment());
break;
case 4:
newFragment = new ConverterFragment();
mDrawerListener = null;
transaction.replace(R.id.container, newFragment);
transaction.replace(R.id.container, new ConverterFragment());
break;
case 5:
newFragment = new CalculatorFragment();
mDrawerListener = (CalculatorFragment) newFragment;
transaction.replace(R.id.container, newFragment);
transaction.replace(R.id.container, new CalculatorFragment());
break;
default:
throw new IllegalArgumentException("unknown fragment to switch to: " + position);
Expand Down Expand Up @@ -323,10 +303,7 @@ private void restoreNavigationIcon() {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
//Notify the listeners
if (mDrawerListener != null) {
mDrawerListener.onDrawerOpened();
}
Utility.hideKeyboard(MainActivity.this);
}
};

Expand All @@ -340,15 +317,4 @@ public void run() {

mDrawerLayout.addDrawerListener(mDrawerToggle);
}

/**
* Interface for listening drawer open events.
*/
public interface OnDrawerOpenedListener {

/**
* Called when the navigation drawer is opened.
*/
void onDrawerOpened();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* Calculator fragment. Let's the user create a list of items and it will calculate the total value
* of the items
*/
public class CalculatorFragment extends BptfFragment implements CalculatorView, MainActivity.OnDrawerOpenedListener{
public class CalculatorFragment extends BptfFragment implements CalculatorView {

@Inject CalculatorPresenter mPresenter;

Expand Down Expand Up @@ -189,11 +189,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return true;
}

@Override
public void onDrawerOpened() {
expandToolbar();
}

@Override
public void updatePrices(Price totalPrice) {
try {
Expand All @@ -206,14 +201,6 @@ public void updatePrices(Price totalPrice) {
}
}

/**
* Fully expand the toolbar with animation.
*/
private void expandToolbar() {
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams()).getBehavior();
behavior.onNestedFling(mCoordinatorLayout, mAppBarLayout, null, 0, -1000, true);
}

@Override
public void showItems(List<Item> items, List<Integer> count, Price totalPrice) {
updatePrices(totalPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* A simple {@link Fragment} subclass.
*/
public class FavoritesFragment extends BptfFragment implements FavoritesView,
MainActivity.OnDrawerOpenedListener, FavoritesAdapter.OnMoreListener {
FavoritesAdapter.OnMoreListener {

@Inject FavoritesPresenter mPresenter;

Expand Down Expand Up @@ -177,11 +177,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

@Override
public void onDrawerOpened() {
expandToolbar();
}

@OnClick(R.id.fab)
public void addItem() {
startActivityForResult(new Intent(getActivity(), ItemChooserActivity.class), MainActivity.REQUEST_NEW_ITEM);
Expand All @@ -193,14 +188,6 @@ public void showFavorites(List<Item> items) {
mAdapter.notifyDataSetChanged();
}

/**
* Fully expand the toolbar with animation.
*/
private void expandToolbar() {
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams()).getBehavior();
behavior.onNestedFling(mCoordinatorLayout, mAppBarLayout, null, 0, -1000, true);
}

@Override
public void onMoreClicked(View view, final Item item) {
PopupMenu menu = new PopupMenu(getActivity(), view);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import com.tlongdev.bktf.model.Item;
import com.tlongdev.bktf.model.Price;
import com.tlongdev.bktf.presenter.fragment.RecentsPresenter;
import com.tlongdev.bktf.ui.activity.MainActivity;
import com.tlongdev.bktf.ui.activity.PriceHistoryActivity;
import com.tlongdev.bktf.ui.activity.SearchActivity;
import com.tlongdev.bktf.ui.view.fragment.RecentsView;
Expand All @@ -72,7 +71,7 @@
* recents fragment. Shows a list of all the prices orderd by the time of the price update.
*/
public class RecentsFragment extends BptfFragment implements RecentsView,
SwipeRefreshLayout.OnRefreshListener, MainActivity.OnDrawerOpenedListener, RecentsAdapter.OnMoreListener {
SwipeRefreshLayout.OnRefreshListener, RecentsAdapter.OnMoreListener {

@Inject RecentsPresenter mPresenter;

Expand Down Expand Up @@ -202,20 +201,6 @@ public void onRefresh() {
mPresenter.downloadPrices();
}

@Override
public void onDrawerOpened() {
expandToolbar();
}

/**
* Fully expand the toolbar with animation.
*/
private void expandToolbar() {
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams)
mAppBarLayout.getLayoutParams()).getBehavior();
behavior.onNestedFling(mCoordinatorLayout, mAppBarLayout, null, 0, -1000, true);
}

@Override
public void showPrices(Cursor prices) {
mAdapter.swapCursor(prices);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
import com.tlongdev.bktf.adapter.UnusualAdapter;
import com.tlongdev.bktf.model.Item;
import com.tlongdev.bktf.presenter.fragment.UnusualPresenter;
import com.tlongdev.bktf.ui.activity.MainActivity;
import com.tlongdev.bktf.ui.activity.SearchActivity;
import com.tlongdev.bktf.ui.activity.UnusualActivity;
import com.tlongdev.bktf.ui.view.fragment.UnusualView;
import com.tlongdev.bktf.util.Utility;

import java.util.List;

Expand All @@ -62,7 +60,7 @@
* hats or effects.
*/
public class UnusualFragment extends BptfFragment implements UnusualView,
MainActivity.OnDrawerOpenedListener, TextWatcher, UnusualAdapter.OnItemClickListener {
TextWatcher, UnusualAdapter.OnItemClickListener {

@Inject UnusualPresenter mPresenter;
@Inject Context mContext;
Expand Down Expand Up @@ -217,15 +215,15 @@ public boolean onOptionsItemSelected(MenuItem item) {
//Show hats sorted by their average price
mPresenter.loadUnusualHats("", mCurrentSort);

effectMenuItem.setIcon(R.drawable.ic_star_outline_white);
effectMenuItem.setIcon(R.drawable.ic_star_outline_white_24dp);
getActivity().setTitle(getString(R.string.title_unusuals));

mSearchInput.setHint("Name");
} else {
//Show effects
mPresenter.loadUnusualEffects("", mCurrentSort);

effectMenuItem.setIcon(R.drawable.ic_star_white);
effectMenuItem.setIcon(R.drawable.ic_star_white_24dp);
getActivity().setTitle(getString(R.string.title_effects));

mSearchInput.setHint("Effect");
Expand All @@ -242,20 +240,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
}

/**
* Fully expand the toolbar with animation.
*/
private void expandToolbar() {
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams()).getBehavior();
behavior.onNestedFling(mCoordinatorLayout, mAppBarLayout, null, 0, -1000, true);
}

@Override
public void onDrawerOpened() {
expandToolbar();
Utility.hideKeyboard(getActivity());
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
Expand Down
20 changes: 3 additions & 17 deletions app/src/main/java/com/tlongdev/bktf/ui/fragment/UserFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import com.tlongdev.bktf.customtabs.WebViewFallback;
import com.tlongdev.bktf.model.User;
import com.tlongdev.bktf.presenter.fragment.UserPresenter;
import com.tlongdev.bktf.ui.activity.MainActivity;
import com.tlongdev.bktf.ui.activity.SearchActivity;
import com.tlongdev.bktf.ui.activity.UserBackpackActivity;
import com.tlongdev.bktf.ui.view.fragment.UserView;
Expand All @@ -68,7 +67,7 @@
/**
* Fragment for displaying the user profile.
*/
public class UserFragment extends BptfFragment implements UserView, View.OnClickListener, MainActivity.OnDrawerOpenedListener {
public class UserFragment extends BptfFragment implements UserView, View.OnClickListener {

private static final String USER_PARAM = "user_param";

Expand Down Expand Up @@ -334,8 +333,8 @@ public void updateUserPage(User user) {
}

//Load drawables for player statuses
Drawable statusOk = getResources().getDrawable(R.drawable.ic_done_white);
Drawable statusBad = getResources().getDrawable(R.drawable.ic_close_white);
Drawable statusOk = getResources().getDrawable(R.drawable.ic_done_white_48dp);
Drawable statusBad = getResources().getDrawable(R.drawable.ic_close_white_48dp);
if (statusOk != null) statusOk.setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);
if (statusBad != null) statusBad.setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY);

Expand Down Expand Up @@ -412,19 +411,6 @@ public void updateUserPage(User user) {
backpackSlots.setText("?/?");
}

@Override
public void onDrawerOpened() {
expandToolbar();
}

/**
* Fully expand the toolbar with animation.
*/
private void expandToolbar() {
AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) mAppBarLayout.getLayoutParams()).getBehavior();
behavior.onNestedFling(mCoordinatorLayout, mAppBarLayout, null, 0, -1000, true);
}

@Override
public void showRefreshingAnimation() {
mSwipeRefreshLayout.post(new Runnable() {
Expand Down
11 changes: 0 additions & 11 deletions app/src/main/res/drawable/ic_account_white.xml

This file was deleted.

4 changes: 0 additions & 4 deletions app/src/main/res/drawable/ic_account_white_wrapper.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/res/drawable/ic_add_white.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/res/drawable/ic_arrow_forward.xml

This file was deleted.

Loading

0 comments on commit fe4895a

Please sign in to comment.