forked from organicmaps/organicmaps
[android] Add context menu to DownloaderActivity.
This commit is contained in:
parent
77f87715b1
commit
c5a51623a0
4 changed files with 89 additions and 43 deletions
|
@ -2,8 +2,11 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menuitem_about_dialog"
|
||||
android:title="@string/about"
|
||||
android:icon="@drawable/ic_menu_about"/>
|
||||
android:icon="@drawable/ic_menu_about"
|
||||
android:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:id="@+id/menuitem_settings_activity"
|
||||
android:title="@string/settings"
|
||||
android:icon="@android:drawable/ic_menu_preferences"/>
|
||||
android:icon="@android:drawable/ic_menu_preferences"
|
||||
android:showAsAction="ifRoom"/>
|
||||
</menu>
|
||||
|
|
64
android/src/com/mapswithme/maps/ContextMenu.java
Normal file
64
android/src/com/mapswithme/maps/ContextMenu.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
|
||||
|
||||
public class ContextMenu
|
||||
{
|
||||
private static void onAboutDialogClicked(Activity parent)
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(parent);
|
||||
|
||||
View alertDialogView = inflater.inflate(R.layout.about, null);
|
||||
WebView myWebView = (WebView) alertDialogView.findViewById(R.id.webview_about);
|
||||
myWebView.loadUrl("file:///android_asset/about.html");
|
||||
|
||||
new AlertDialog.Builder(parent)
|
||||
.setView(alertDialogView)
|
||||
.setTitle(R.string.about)
|
||||
.setPositiveButton(R.string.close, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private static void onSettingsClicked(Activity parent)
|
||||
{
|
||||
parent.startActivity(new Intent(parent, SettingsActivity.class));
|
||||
}
|
||||
|
||||
public static boolean onCreateOptionsMenu(Activity parent, Menu menu)
|
||||
{
|
||||
MenuInflater inflater = parent.getMenuInflater();
|
||||
inflater.inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean onOptionsItemSelected(Activity parent, MenuItem item)
|
||||
{
|
||||
final int id = item.getItemId();
|
||||
|
||||
if (id == R.id.menuitem_about_dialog)
|
||||
onAboutDialogClicked(parent);
|
||||
else if (id == R.id.menuitem_settings_activity)
|
||||
onSettingsClicked(parent);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,8 @@ import android.os.StatFs;
|
|||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -704,4 +706,19 @@ public class DownloadUI extends ListActivity implements MapStorage.Listener
|
|||
{
|
||||
getDA().onCountryProgress(getListView(), idx, current, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
return ContextMenu.onCreateOptionsMenu(this, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
if (ContextMenu.onOptionsItemSelected(this, item))
|
||||
return true;
|
||||
else
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,9 @@ import android.os.Environment;
|
|||
import android.telephony.TelephonyManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.mapswithme.maps.location.LocationService;
|
||||
|
@ -622,51 +619,16 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.main, menu);
|
||||
return true;
|
||||
return ContextMenu.onCreateOptionsMenu(this, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item)
|
||||
{
|
||||
final int id = item.getItemId();
|
||||
|
||||
if (id == R.id.menuitem_about_dialog)
|
||||
onAboutDialogClicked();
|
||||
else if (id == R.id.menuitem_settings_activity)
|
||||
onSettingsClicked();
|
||||
if (ContextMenu.onOptionsItemSelected(this, item))
|
||||
return true;
|
||||
else
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onAboutDialogClicked()
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(this);
|
||||
|
||||
View alertDialogView = inflater.inflate(R.layout.about, null);
|
||||
WebView myWebView = (WebView) alertDialogView.findViewById(R.id.webview_about);
|
||||
myWebView.loadUrl("file:///android_asset/about.html");
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setView(alertDialogView)
|
||||
.setTitle(R.string.about)
|
||||
.setPositiveButton(R.string.close, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.cancel();
|
||||
}
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onSettingsClicked()
|
||||
{
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
}
|
||||
|
||||
// Initialized to invalid combination to force update on the first check
|
||||
|
|
Loading…
Add table
Reference in a new issue