|
6 | 6 | import android.content.Intent;
|
7 | 7 | import android.content.SharedPreferences;
|
8 | 8 | import android.content.pm.PackageManager;
|
9 |
| -import android.content.res.Resources; |
10 |
| -import android.content.res.TypedArray; |
11 | 9 | import android.os.Build;
|
12 | 10 | import android.os.Bundle;
|
13 | 11 | import android.support.v4.app.Fragment;
|
14 | 12 | import android.support.v4.content.ContextCompat;
|
15 |
| -import android.util.DisplayMetrics; |
16 | 13 | import android.util.Log;
|
17 |
| -import android.util.TypedValue; |
18 |
| -import android.view.Display; |
19 | 14 | import android.view.LayoutInflater;
|
20 | 15 | import android.view.Menu;
|
21 | 16 | import android.view.MenuInflater;
|
|
28 | 23 | import android.widget.TextView;
|
29 | 24 | import android.widget.Toast;
|
30 | 25 |
|
31 |
| -import java.lang.reflect.Method; |
32 |
| - |
33 | 26 | import butterknife.BindView;
|
34 | 27 | import butterknife.ButterKnife;
|
35 | 28 | import fr.free.nrw.commons.AboutActivity;
|
|
39 | 32 | import fr.free.nrw.commons.nearby.NearbyActivity;
|
40 | 33 |
|
41 | 34 | import static android.app.Activity.RESULT_OK;
|
42 |
| -import static android.content.Context.LOCATION_SERVICE; |
43 | 35 |
|
44 | 36 | public class ContributionsListFragment extends Fragment {
|
45 | 37 |
|
@@ -213,53 +205,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
213 | 205 | menu.findItem(R.id.menu_refresh).setVisible(false);
|
214 | 206 | }
|
215 | 207 |
|
216 |
| - /*http://stackoverflow.com/questions/30076392/how-does-this-strange-condition-happens-when-show-menu-item-icon-in-toolbar-over/30337653#30337653 |
217 |
| - Overriden to show toggle_layout button on overlay menu |
218 |
| - */ |
219 |
| - @Override |
220 |
| - public void onPrepareOptionsMenu(Menu menu) { |
221 |
| - if(menu != null){ |
222 |
| - if(menu.getClass().getSimpleName().equals("MenuBuilder")){ |
223 |
| - try{ |
224 |
| - Method m = menu.getClass().getDeclaredMethod( |
225 |
| - "setOptionalIconsVisible", Boolean.TYPE); |
226 |
| - m.setAccessible(true); |
227 |
| - m.invoke(menu, true); |
228 |
| - } |
229 |
| - catch(NoSuchMethodException e){ |
230 |
| - Log.e(TAG, "onMenuOpened", e); |
231 |
| - } |
232 |
| - catch(Exception e){ |
233 |
| - throw new RuntimeException(e); |
234 |
| - } |
235 |
| - } |
236 |
| - |
237 |
| - MenuItem galleryMenu = menu.findItem(R.id.menu_from_gallery); |
238 |
| - |
239 |
| - // Get background resource id to recognize current themes |
240 |
| - TypedArray typedArray = getActivity().getTheme().obtainStyledAttributes(new int[] {R.attr.mainBackground}); |
241 |
| - int galleryIconResourceId = typedArray.getResourceId(0, 0); |
242 |
| - typedArray.recycle(); |
243 |
| - |
244 |
| - // Get width in dp http://stackoverflow.com/questions/11999260/check-if-menuitem-is-in-actionbar-overflow |
245 |
| - DisplayMetrics metrics = new DisplayMetrics(); |
246 |
| - Display display = getActivity().getWindowManager().getDefaultDisplay(); |
247 |
| - display.getMetrics(metrics); |
248 |
| - float logicalDensity = metrics.density; |
249 |
| - int dp = (int) (metrics.widthPixels / logicalDensity + 0.5); |
250 |
| - |
251 |
| - if(dp < 360) { // only two icons, there is no room |
252 |
| - if(galleryIconResourceId==getActivity().obtainStyledAttributes(R.style.LightAppTheme, new int[] {R.attr.mainBackground}).getResourceId(0, 0)){ |
253 |
| - galleryMenu.setIcon(R.drawable.ic_photo_black_24dp); //If theme is light, display dark icon on overlay menu |
254 |
| - }else{ |
255 |
| - galleryMenu.setIcon(R.drawable.ic_photo_white_24dp); //If theme is dark, display light icon on overlay menu |
256 |
| - } |
257 |
| - } |
258 |
| - } |
259 |
| - super.onPrepareOptionsMenu(menu); |
260 |
| - } |
261 |
| - |
262 |
| - |
263 | 208 | @Override
|
264 | 209 | public void onCreate(Bundle savedInstanceState) {
|
265 | 210 | super.onCreate(savedInstanceState);
|
|
0 commit comments