Info button on toolbar
This commit is contained in:
parent
3139d41ba4
commit
90aa21be1d
@ -29,7 +29,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -7,6 +7,7 @@ import android.app.FragmentTransaction;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
@ -20,16 +21,20 @@ import android.support.v7.app.ActionBarDrawerToggle;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.SearchView;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.PopupWindow;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||||
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
import com.uam.wmi.findmytutor.utils.ActiveFragment;
|
||||||
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
import com.uam.wmi.findmytutor.utils.FeedbackUtils;
|
||||||
|
import com.uam.wmi.findmytutor.utils.InfoHelperUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
import com.uam.wmi.findmytutor.utils.RxSearchObservable;
|
||||||
|
|
||||||
@ -76,6 +81,7 @@ public abstract class BaseActivity
|
|||||||
private ActiveFragment activeFragment = ActiveFragment.NONE;
|
private ActiveFragment activeFragment = ActiveFragment.NONE;
|
||||||
private Fragment activeBottomMenu = null;
|
private Fragment activeBottomMenu = null;
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
|
public MenuItem infoMenuItem;
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
@Override
|
@Override
|
||||||
@ -266,6 +272,8 @@ public abstract class BaseActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||||
|
infoMenuItem = menu.findItem(R.id.action_info);
|
||||||
|
|
||||||
|
|
||||||
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
|
||||||
searchView = (SearchView) myActionMenuItem.getActionView();
|
searchView = (SearchView) myActionMenuItem.getActionView();
|
||||||
@ -313,6 +321,41 @@ public abstract class BaseActivity
|
|||||||
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
|
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
|
||||||
return true;
|
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());
|
||||||
|
int location[] = new int[2];
|
||||||
|
// Get the View's(the one that was clicked in the Fragment) location
|
||||||
|
View anchorView= getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
|
||||||
|
anchorView.getLocationOnScreen(location);
|
||||||
|
// Using location, the PopupWindow will be displayed right under anchorView
|
||||||
|
popupWindow.showAsDropDown(anchorView,0,170,Gravity.RIGHT);
|
||||||
|
// popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY,
|
||||||
|
// location[0] + anchorView.getWidth() / 2, location[1] + anchorView.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +131,7 @@ public class MapActivity extends BaseActivity
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
findViewById(R.id.mapInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v, R.layout.info_popup_map));
|
findViewById(R.id.mapInfoImageButton).setOnClickListener(v-> InfoHelperUtils.infoPopUp(v, R.layout.info_popup_map));
|
||||||
selectLocationButton = findViewById(R.id.select_location_button);
|
selectLocationButton = findViewById(R.id.select_location_button);
|
||||||
removeLocationButton = findViewById(R.id.remove_location_button);
|
removeLocationButton = findViewById(R.id.remove_location_button);
|
||||||
|
@ -8,4 +8,11 @@
|
|||||||
app:showAsAction="always"
|
app:showAsAction="always"
|
||||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||||
android:title="@string/search"/>
|
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>
|
</menu>
|
Loading…
Reference in New Issue
Block a user