Fix enabling BG

This commit is contained in:
Mieszko Wrzeszczyński 2018-12-16 16:19:32 +01:00
commit e2a6bfd56c
9 changed files with 44 additions and 18 deletions

View File

@ -29,7 +29,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@ -7,6 +7,7 @@ import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
@ -21,10 +22,13 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.Toast;
import com.uam.wmi.findmytutor.R;
@ -78,6 +82,7 @@ public abstract class BaseActivity
private ActiveFragment activeFragment = ActiveFragment.NONE;
private Fragment activeBottomMenu = null;
private SearchView searchView;
public MenuItem infoMenuItem;
@SuppressLint("CheckResult")
@Override
@ -278,6 +283,8 @@ public abstract class BaseActivity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
infoMenuItem = menu.findItem(R.id.action_info);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
searchView = (SearchView) myActionMenuItem.getActionView();
@ -325,6 +332,33 @@ public abstract class BaseActivity
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
if (item.getItemId()==R.id.action_info){
int layoutID;
switch (activeFragment){
case SHARED_PREFERENCES:
layoutID = R.layout.info_popup_sharing_tab;
break;
case USER_LIST:
layoutID = R.layout.info_popup_userlist;
break;
default:
layoutID = R.layout.info_popup_map;
}
View popupView = getLayoutInflater().inflate(layoutID,null);
PopupWindow popupWindow = new PopupWindow(popupView,
LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
// If the PopupWindow should be focusable
popupWindow.setFocusable(true);
// If you need the PopupWindow to dismiss when when touched outside
popupWindow.setBackgroundDrawable(new ColorDrawable());
// Get the View's(the one that was clicked in the Fragment) location
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
popupWindow.showAtLocation(anchorView,Gravity.TOP|Gravity.END, 0, 0);
}
return super.onOptionsItemSelected(item);
}

View File

@ -126,7 +126,7 @@ public class MapActivity extends BaseActivity
};
findViewById(R.id.mapInfoImageButton).setOnClickListener(v -> InfoHelperUtils.infoPopUp(v, R.layout.info_popup_map));
selectLocationButton = findViewById(R.id.select_location_button);
removeLocationButton = findViewById(R.id.remove_location_button);
mapView = findViewById(R.id.mapView);

View File

@ -192,6 +192,7 @@ public class SharingFragment extends PreferenceFragment implements SharedPrefere
PrefUtils.putCurrentManualLocation(getApplicationContext(), temp.getPredefinedCoordinateId());
PrefUtils.putCurrentManualLocationName(getApplicationContext(), (String) lp.getEntries()[Integer.parseInt((String) newValue)]);
lp.setSummary(lp.getEntries()[Integer.parseInt((String) newValue)]);
((MapActivity) getActivity()).handleBackgroundTaskLifeCycle();
return true;
});

View File

@ -84,7 +84,6 @@ public class UsersListFragment extends Fragment {
public void onViewCreated(View view, Bundle savedInstanceState) {
ButterKnife.bind(this, view);
view.findViewById(R.id.userListInfoImageButton).setOnClickListener(v -> InfoHelperUtils.infoPopUp(v,R.layout.info_popup_userlist));
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);

View File

@ -20,12 +20,6 @@
</com.mapbox.mapboxsdk.maps.MapView>
<ImageButton
android:id="@+id/mapInfoImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
mapbox:srcCompat="@drawable/outline_info_24"/>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"

View File

@ -6,8 +6,6 @@
android:fontFamily="@font/lato_regular"
android:layout_height="match_parent">
<com.uam.wmi.findmytutor.utils.SharingInfoPopupButtonPreference/>
<PreferenceCategory
android:title="@string/settings_category_location"
android:key="category_sharing">

View File

@ -10,13 +10,6 @@
<include layout="@layout/users_list_main" />
<ImageButton
android:id="@+id/userListInfoImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
mapbox:srcCompat="@drawable/outline_info_24"/>
</android.support.design.widget.CoordinatorLayout>

View File

@ -8,4 +8,11 @@
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView"
android:title="@string/search"/>
<item
android:id="@+id/action_info"
app:showAsAction="ifRoom|collapseActionView"
android:icon="@drawable/outline_info_24"
android:titleCondensed="@string/access_token"
android:actionLayout="@layout/info_popup_map"
android:title="Info" />
</menu>