forked from organicmaps/organicmaps
[android] Code reformatting
This commit is contained in:
parent
bf6ab8d969
commit
d22468ae04
3 changed files with 432 additions and 445 deletions
|
@ -65,40 +65,54 @@ import com.mapswithme.util.statistics.Statistics;
|
|||
import com.nvidia.devtech.NvEventQueueActivity;
|
||||
|
||||
public class MWMActivity extends NvEventQueueActivity
|
||||
implements LocationService.Listener,
|
||||
OnBalloonListener,
|
||||
DrawerListener,
|
||||
OnVisibilityChangedListener
|
||||
implements LocationService.Listener,
|
||||
OnBalloonListener,
|
||||
DrawerListener,
|
||||
OnVisibilityChangedListener
|
||||
{
|
||||
private final static String TAG = "MWMActivity";
|
||||
public static final String EXTRA_TASK = "map_task";
|
||||
|
||||
private final static String TAG = "MWMActivity";
|
||||
private static final int PRO_VERSION_DIALOG = 110001;
|
||||
private static final String PRO_VERSION_DIALOG_MSG = "pro_version_dialog_msg";
|
||||
private static final int PROMO_DIALOG = 110002;
|
||||
|
||||
private final static String EXTRA_CONSUMED = "mwm.extra.intent.processed";
|
||||
// Need it for search
|
||||
private static final String EXTRA_SEARCH_RES_SINGLE = "search_res_index";
|
||||
// Map tasks that we run AFTER rendering initialized
|
||||
private final Stack<MapTask> mTasks = new Stack<MWMActivity.MapTask>();
|
||||
private MWMApplication mApplication = null;
|
||||
private BroadcastReceiver m_externalStorageReceiver = null;
|
||||
private StoragePathManager m_pathManager = new StoragePathManager();
|
||||
private AlertDialog m_storageDisconnectedDialog = null;
|
||||
|
||||
private ImageButton mLocationButton;
|
||||
private SurfaceView mMapSurface;
|
||||
|
||||
|
||||
// Map tasks that we run AFTER rendering initialized
|
||||
private final Stack<MapTask> mTasks = new Stack<MWMActivity.MapTask>();
|
||||
|
||||
// Info box (place page).
|
||||
private MapInfoView mInfoView;
|
||||
|
||||
// Drawer components
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private View mMainDrawer;
|
||||
|
||||
private SearchController mSearchController;
|
||||
|
||||
private String mProDialogMessage;
|
||||
private boolean m_needCheckUpdate = true;
|
||||
private boolean mRenderingInitialized = false;
|
||||
private int m_compassStatusListenerID = -1;
|
||||
// Initialized to invalid combination to force update on the first check
|
||||
private boolean m_storageAvailable = false;
|
||||
private boolean m_storageWritable = true;
|
||||
|
||||
public static Intent createShowMapIntent(Context context, Index index)
|
||||
{
|
||||
return new Intent(context, DownloadResourcesActivity.class)
|
||||
.putExtra(DownloadResourcesActivity.EXTRA_COUNTRY_INDEX, index);
|
||||
}
|
||||
|
||||
public static void startWithSearchResult(Context context, boolean single)
|
||||
{
|
||||
final Intent mapIntent = new Intent(context, MWMActivity.class);
|
||||
mapIntent.putExtra(EXTRA_SEARCH_RES_SINGLE, single);
|
||||
context.startActivity(mapIntent);
|
||||
// Next we need to handle intent
|
||||
}
|
||||
|
||||
private native void deactivatePopup();
|
||||
|
||||
|
@ -160,8 +174,9 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
{
|
||||
LocationButtonImageSetter.setButtonViewFromState(
|
||||
hasPosition
|
||||
? ButtonState.HAS_LOCATION
|
||||
: ButtonState.WAITING_LOCATION, mLocationButton);
|
||||
? ButtonState.HAS_LOCATION
|
||||
: ButtonState.WAITING_LOCATION, mLocationButton
|
||||
);
|
||||
}
|
||||
resumeLocation();
|
||||
}
|
||||
|
@ -225,19 +240,19 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
public void run()
|
||||
{
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(getString(R.string.unsupported_phone))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.close), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
getActivity().moveTaskToBack(true);
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
.setMessage(getString(R.string.unsupported_phone))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.close), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
getActivity().moveTaskToBack(true);
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -311,22 +326,18 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
LocationButtonImageSetter.setButtonViewFromState(ButtonState.NO_LOCATION, mLocationButton);
|
||||
}
|
||||
|
||||
private boolean m_needCheckUpdate = true;
|
||||
|
||||
private boolean mRenderingInitialized = false;
|
||||
|
||||
private void ShowAlertDlg(int tittleID)
|
||||
{
|
||||
new AlertDialog.Builder(this)
|
||||
.setCancelable(false)
|
||||
.setMessage(tittleID)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which) { dlg.dismiss(); }
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
.setCancelable(false)
|
||||
.setMessage(tittleID)
|
||||
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which) { dlg.dismiss(); }
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void checkKitkatMigrationMove()
|
||||
|
@ -382,6 +393,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
{
|
||||
runDownloadActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancel()
|
||||
{
|
||||
|
@ -400,29 +412,29 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
private void showDialogImpl(final int dlgID, int resMsg, DialogInterface.OnClickListener okListener)
|
||||
{
|
||||
new AlertDialog.Builder(this)
|
||||
.setCancelable(false)
|
||||
.setMessage(getString(resMsg))
|
||||
.setPositiveButton(getString(R.string.ok), okListener)
|
||||
.setNeutralButton(getString(R.string.never), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
mApplication.submitDialogResult(dlgID, MWMApplication.NEVER);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.later), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
mApplication.submitDialogResult(dlgID, MWMApplication.LATER);
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
.setCancelable(false)
|
||||
.setMessage(getString(resMsg))
|
||||
.setPositiveButton(getString(R.string.ok), okListener)
|
||||
.setNeutralButton(getString(R.string.never), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
mApplication.submitDialogResult(dlgID, MWMApplication.NEVER);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.later), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
mApplication.submitDialogResult(dlgID, MWMApplication.LATER);
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
private void showFacebookPage()
|
||||
|
@ -435,8 +447,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
// Profile id is taken from http://graph.facebook.com/MapsWithMe
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/111923085594432")));
|
||||
}
|
||||
catch (final Exception e)
|
||||
} catch (final Exception e)
|
||||
{
|
||||
// Show Facebook page in browser.
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/MapsWithMe")));
|
||||
|
@ -445,7 +456,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
private boolean isChinaISO(String iso)
|
||||
{
|
||||
final String arr[] = { "CN", "CHN", "HK", "HKG", "MO", "MAC" };
|
||||
final String arr[] = {"CN", "CHN", "HK", "HKG", "MO", "MAC"};
|
||||
for (final String s : arr)
|
||||
if (iso.equalsIgnoreCase(s))
|
||||
return true;
|
||||
|
@ -486,17 +497,18 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
!isChinaRegion())
|
||||
{
|
||||
showDialogImpl(MWMApplication.FACEBOOK, R.string.share_on_facebook_text,
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
mApplication.submitDialogResult(MWMApplication.FACEBOOK, MWMApplication.OK);
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
mApplication.submitDialogResult(MWMApplication.FACEBOOK, MWMApplication.OK);
|
||||
|
||||
dlg.dismiss();
|
||||
showFacebookPage();
|
||||
}
|
||||
});
|
||||
dlg.dismiss();
|
||||
showFacebookPage();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,14 +531,12 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
try
|
||||
{
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(mApplication.getProVersionURL())));
|
||||
}
|
||||
catch (final Exception e1)
|
||||
} catch (final Exception e1)
|
||||
{
|
||||
try
|
||||
{
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(mApplication.getDefaultProVersionURL())));
|
||||
}
|
||||
catch (final Exception e2)
|
||||
} catch (final Exception e2)
|
||||
{
|
||||
/// @todo Probably we should show some alert toast here?
|
||||
Log.w(TAG, "Can't run activity" + e2);
|
||||
|
@ -541,16 +551,17 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
mApplication.shouldShowDialog(MWMApplication.BUYPRO))
|
||||
{
|
||||
showDialogImpl(MWMApplication.BUYPRO, R.string.pro_version_available,
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
mApplication.submitDialogResult(MWMApplication.BUYPRO, MWMApplication.OK);
|
||||
dlg.dismiss();
|
||||
runProVersionMarketActivity();
|
||||
}
|
||||
});
|
||||
new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
mApplication.submitDialogResult(MWMApplication.BUYPRO, MWMApplication.OK);
|
||||
dlg.dismiss();
|
||||
runProVersionMarketActivity();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,6 +585,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
{
|
||||
runDownloadActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doCancel()
|
||||
{
|
||||
|
@ -614,7 +626,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
setContentView(R.layout.activity_map);
|
||||
super.onCreate(savedInstanceState);
|
||||
mApplication = (MWMApplication)getApplication();
|
||||
mApplication = (MWMApplication) getApplication();
|
||||
|
||||
// Do not turn off the screen while benchmarking
|
||||
if (mApplication.nativeIsBenchmarking())
|
||||
|
@ -622,11 +634,10 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
nativeConnectDownloadButton();
|
||||
|
||||
//set up view
|
||||
// Set up view
|
||||
mLocationButton = (ImageButton) findViewById(R.id.map_button_myposition);
|
||||
mMapSurface = (SurfaceView) findViewById(R.id.map_surfaceview);
|
||||
|
||||
setUpDrawer();
|
||||
yotaSetup();
|
||||
|
||||
setUpInfoBox();
|
||||
|
@ -692,18 +703,18 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
else
|
||||
{
|
||||
new AlertDialog.Builder(MWMActivity.this)
|
||||
.setMessage(R.string.unknown_current_position)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
.setMessage(R.string.unknown_current_position)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(android.R.string.ok, new Dialog.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -806,7 +817,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
public void onClick(View v)
|
||||
{
|
||||
final double[] latLon = Framework.getScreenRectCenter();
|
||||
final double zoom = Framework.getDrawScale();
|
||||
final double zoom = Framework.getDrawScale();
|
||||
|
||||
final LocationState locState = mApplication.getLocationState();
|
||||
|
||||
|
@ -848,8 +859,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final static String EXTRA_CONSUMED = "mwm.extra.intent.processed";
|
||||
//@}
|
||||
|
||||
private void addTask(Intent intent)
|
||||
{
|
||||
|
@ -870,7 +880,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
@ -892,7 +901,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
|
||||
{
|
||||
final DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
drawerItemsPadding = Math.max(dm.heightPixels, dm.widthPixels)/5;
|
||||
drawerItemsPadding = Math.max(dm.heightPixels, dm.widthPixels) / 5;
|
||||
}
|
||||
|
||||
findViewById(R.id.scroll_up).setPadding(0, drawerItemsPadding, 0, 0);
|
||||
|
@ -915,41 +924,39 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
if (!Utils.isAmazonDevice())
|
||||
{
|
||||
new AlertDialog.Builder(this).setTitle(R.string.location_is_disabled_long_text)
|
||||
.setPositiveButton(R.string.connection_settings, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
try
|
||||
.setPositiveButton(R.string.connection_settings, new DialogInterface.OnClickListener()
|
||||
{
|
||||
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||
}
|
||||
catch (final Exception e1)
|
||||
{
|
||||
// On older Android devices location settings are merged with security
|
||||
try
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS));
|
||||
}
|
||||
catch (final Exception e2)
|
||||
{
|
||||
Log.w(TAG, "Can't run activity" + e2);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||
} catch (final Exception e1)
|
||||
{
|
||||
// On older Android devices location settings are merged with security
|
||||
try
|
||||
{
|
||||
startActivity(new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS));
|
||||
} catch (final Exception e2)
|
||||
{
|
||||
Log.w(TAG, "Can't run activity" + e2);
|
||||
}
|
||||
}
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.close, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
}
|
||||
else if (errorCode == LocationService.ERROR_GPS_OFF)
|
||||
|
@ -971,11 +978,10 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
@Override
|
||||
public void onCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy)
|
||||
{
|
||||
final double angles[] = { magneticNorth, trueNorth };
|
||||
final double angles[] = {magneticNorth, trueNorth};
|
||||
getLocationService().correctCompassAngles(getWindowManager().getDefaultDisplay(), angles);
|
||||
nativeCompassUpdated(time, angles[0], angles[1], accuracy);
|
||||
}
|
||||
//@}
|
||||
|
||||
public void onCompassStatusChanged(int newStatus)
|
||||
{
|
||||
|
@ -1001,9 +1007,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
private int m_compassStatusListenerID = -1;
|
||||
|
||||
private void startWatchingCompassStatusUpdate()
|
||||
{
|
||||
m_compassStatusListenerID = mApplication.getLocationState().addCompassStatusListener(this);
|
||||
|
@ -1038,8 +1041,8 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
startWatchingExternalStorage();
|
||||
|
||||
UiUtils.showIf(SettingsActivity.isZoomButtonsEnabled(mApplication),
|
||||
findViewById(R.id.map_button_plus),
|
||||
findViewById(R.id.map_button_minus));
|
||||
findViewById(R.id.map_button_plus),
|
||||
findViewById(R.id.map_button_minus));
|
||||
|
||||
alignControls();
|
||||
|
||||
|
@ -1047,31 +1050,27 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
mInfoView.onResume();
|
||||
}
|
||||
|
||||
// Initialized to invalid combination to force update on the first check
|
||||
private boolean m_storageAvailable = false;
|
||||
private boolean m_storageWriteable = true;
|
||||
|
||||
private void updateExternalStorageState()
|
||||
{
|
||||
boolean available, writeable;
|
||||
boolean available, writable;
|
||||
final String state = Environment.getExternalStorageState();
|
||||
if (Environment.MEDIA_MOUNTED.equals(state))
|
||||
{
|
||||
available = writeable = true;
|
||||
available = writable = true;
|
||||
}
|
||||
else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state))
|
||||
{
|
||||
available = true;
|
||||
writeable = false;
|
||||
writable = false;
|
||||
}
|
||||
else
|
||||
available = writeable = false;
|
||||
available = writable = false;
|
||||
|
||||
if (m_storageAvailable != available || m_storageWriteable != writeable)
|
||||
if (m_storageAvailable != available || m_storageWritable != writable)
|
||||
{
|
||||
m_storageAvailable = available;
|
||||
m_storageWriteable = writeable;
|
||||
handleExternalStorageState(available, writeable);
|
||||
m_storageWritable = writable;
|
||||
handleExternalStorageState(available, writable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1107,10 +1106,10 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
if (m_storageDisconnectedDialog == null)
|
||||
{
|
||||
m_storageDisconnectedDialog = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.external_storage_is_not_available)
|
||||
.setMessage(getString(R.string.disconnect_usb_cable))
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
.setTitle(R.string.external_storage_is_not_available)
|
||||
.setMessage(getString(R.string.disconnect_usb_cable))
|
||||
.setCancelable(false)
|
||||
.create();
|
||||
}
|
||||
m_storageDisconnectedDialog.show();
|
||||
}
|
||||
|
@ -1143,7 +1142,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
{
|
||||
if (id == PRO_VERSION_DIALOG)
|
||||
{
|
||||
((AlertDialog)dialog).setMessage(mProDialogMessage);
|
||||
((AlertDialog) dialog).setMessage(mProDialogMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1158,42 +1157,42 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
if (id == PRO_VERSION_DIALOG)
|
||||
{
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage("")
|
||||
.setPositiveButton(getString(R.string.get_it_now), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
runProVersionMarketActivity();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.setOnKeyListener(new OnKeyListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
|
||||
{
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)
|
||||
.setMessage("")
|
||||
.setPositiveButton(getString(R.string.get_it_now), new DialogInterface.OnClickListener()
|
||||
{
|
||||
if (ActivationSettings.isSearchActivated(getApplicationContext()))
|
||||
return false;
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
runProVersionMarketActivity();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dlg, int which)
|
||||
{
|
||||
dlg.dismiss();
|
||||
}
|
||||
})
|
||||
.setOnKeyListener(new OnKeyListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event)
|
||||
{
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN || keyCode == KeyEvent.KEYCODE_VOLUME_UP)
|
||||
{
|
||||
if (ActivationSettings.isSearchActivated(getApplicationContext()))
|
||||
return false;
|
||||
|
||||
showDialog(PROMO_DIALOG);
|
||||
dismissDialog(PRO_VERSION_DIALOG);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.create();
|
||||
showDialog(PROMO_DIALOG);
|
||||
dismissDialog(PRO_VERSION_DIALOG);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}
|
||||
else if (id == PROMO_DIALOG)
|
||||
return new PromocodeActivationDialog(this);
|
||||
|
@ -1207,6 +1206,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
m_externalStorageReceiver = null;
|
||||
}
|
||||
|
||||
/// Map tasks invoked by intent processing.
|
||||
|
||||
private void toggleDrawer()
|
||||
{
|
||||
|
@ -1236,49 +1236,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
/// Map tasks invoked by intent processing.
|
||||
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
public boolean run(MWMActivity target);
|
||||
}
|
||||
|
||||
public static class OpenUrlTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String mUrl;
|
||||
|
||||
public OpenUrlTask(String url)
|
||||
{
|
||||
Utils.checkNotNull(url);
|
||||
mUrl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
{
|
||||
return target.showMapForUrl(mUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShowCountryTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Index mIndex;
|
||||
|
||||
public ShowCountryTask(Index index)
|
||||
{
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
{
|
||||
target.getMapStorage().showCountry(mIndex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Callbacks from native map objects touch event.
|
||||
|
||||
@Override
|
||||
|
@ -1407,74 +1364,72 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
private void _showInfoBox(boolean show, boolean animate)
|
||||
{
|
||||
// if ((show == mIsInfoBoxVisible) && animate)
|
||||
// return;
|
||||
//
|
||||
// mIsInfoBoxVisible = show;
|
||||
//
|
||||
// final long duration = 200;
|
||||
// if (show)
|
||||
// {
|
||||
// if (animate)
|
||||
// {
|
||||
// final Animation slideIn = new TranslateAnimation(
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f, // X
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 1.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f); // Y
|
||||
// slideIn.setDuration(duration);
|
||||
//
|
||||
// mInfoView.startAnimation(slideIn);
|
||||
// mapButtonBottom.startAnimation(slideIn);
|
||||
//
|
||||
// UiUtils.showAndAnimate(mInfoView, slideIn);
|
||||
// mapButtonBottom.startAnimation(slideIn);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// UiUtils.show(mInfoView);
|
||||
// UiUtils.show(mapButtonBottom);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (animate)
|
||||
// {
|
||||
// final Animation slideOutInfo = new TranslateAnimation(
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f, // X
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 1.f); // Y
|
||||
// slideOutInfo.setDuration(duration);
|
||||
//
|
||||
// final Animation slideOutButtons = new TranslateAnimation(
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f, // X
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, -1.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f); // Y
|
||||
// slideOutButtons.setDuration(duration);
|
||||
//
|
||||
// mapButtonBottom.startAnimation(slideOutButtons);
|
||||
// UiUtils.animateAndHide(mInfoView, slideOutInfo);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// UiUtils.hide(mInfoView);
|
||||
// UiUtils.show(mapButtonBottom);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static Intent createShowMapIntent(Context context, Index index)
|
||||
{
|
||||
return new Intent(context, DownloadResourcesActivity.class)
|
||||
.putExtra(DownloadResourcesActivity.EXTRA_COUNTRY_INDEX, index);
|
||||
// if ((show == mIsInfoBoxVisible) && animate)
|
||||
// return;
|
||||
//
|
||||
// mIsInfoBoxVisible = show;
|
||||
//
|
||||
// final long duration = 200;
|
||||
// if (show)
|
||||
// {
|
||||
// if (animate)
|
||||
// {
|
||||
// final Animation slideIn = new TranslateAnimation(
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f, // X
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 1.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f); // Y
|
||||
// slideIn.setDuration(duration);
|
||||
//
|
||||
// mInfoView.startAnimation(slideIn);
|
||||
// mapButtonBottom.startAnimation(slideIn);
|
||||
//
|
||||
// UiUtils.showAndAnimate(mInfoView, slideIn);
|
||||
// mapButtonBottom.startAnimation(slideIn);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// UiUtils.show(mInfoView);
|
||||
// UiUtils.show(mapButtonBottom);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (animate)
|
||||
// {
|
||||
// final Animation slideOutInfo = new TranslateAnimation(
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f, // X
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 1.f); // Y
|
||||
// slideOutInfo.setDuration(duration);
|
||||
//
|
||||
// final Animation slideOutButtons = new TranslateAnimation(
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, 0.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f, // X
|
||||
// TranslateAnimation.RELATIVE_TO_SELF, -1.f, TranslateAnimation.RELATIVE_TO_SELF, 0.f); // Y
|
||||
// slideOutButtons.setDuration(duration);
|
||||
//
|
||||
// mapButtonBottom.startAnimation(slideOutButtons);
|
||||
// UiUtils.animateAndHide(mInfoView, slideOutInfo);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// UiUtils.hide(mInfoView);
|
||||
// UiUtils.show(mapButtonBottom);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private native void nativeStorageConnected();
|
||||
|
||||
private native void nativeStorageDisconnected();
|
||||
|
||||
private native void nativeConnectDownloadButton();
|
||||
|
||||
private native void nativeDownloadCountry();
|
||||
|
||||
private native void nativeDestroy();
|
||||
|
||||
private native void nativeOnLocationError(int errorCode);
|
||||
|
||||
private native void nativeLocationUpdated(long time, double lat, double lon, float accuracy, double altitude, float speed, float bearing);
|
||||
|
||||
private native void nativeCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy);
|
||||
|
||||
private native boolean nativeIsInChina(double lat, double lon);
|
||||
|
@ -1500,7 +1455,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
public void onDrawerStateChanged(int arg0) {}
|
||||
|
||||
@Override
|
||||
public void onHeadVisibilityChanged(boolean isVisible)
|
||||
public void onPPPVisibilityChanged(boolean isVisible)
|
||||
{
|
||||
final View mapButtonBottom = findViewById(R.id.map_buttons_bottom_ref);
|
||||
final RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mapButtonBottom.getLayoutParams();
|
||||
|
@ -1509,21 +1464,51 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBodyVisibilityChanged(boolean isVisible)
|
||||
public void onPPVisibilityChanged(boolean isVisible)
|
||||
{
|
||||
// If body is visible -- hide my location and drawer buttons
|
||||
UiUtils.showIf(!isVisible, findViewById(R.id.map_buttons_bottom_ref));
|
||||
}
|
||||
|
||||
// Need it for search
|
||||
private static final String EXTRA_SEARCH_RES_SINGLE = "search_res_index";
|
||||
|
||||
public static void startWithSearchResult(Context context, boolean single)
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
final Intent mapIntent = new Intent(context, MWMActivity.class);
|
||||
mapIntent.putExtra(EXTRA_SEARCH_RES_SINGLE, single);
|
||||
context.startActivity(mapIntent);
|
||||
// Next we need to handle intent
|
||||
public boolean run(MWMActivity target);
|
||||
}
|
||||
|
||||
public static class OpenUrlTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String mUrl;
|
||||
|
||||
public OpenUrlTask(String url)
|
||||
{
|
||||
Utils.checkNotNull(url);
|
||||
mUrl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
{
|
||||
return target.showMapForUrl(mUrl);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShowCountryTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Index mIndex;
|
||||
|
||||
public ShowCountryTask(Index index)
|
||||
{
|
||||
mIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
{
|
||||
target.getMapStorage().showCountry(mIndex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class SearchController implements OnClickListener
|
|||
// Data
|
||||
private String mQuery = "";
|
||||
|
||||
// Singlton
|
||||
// Singleton
|
||||
// No threadsafety needed as everything goes on UI
|
||||
private static SearchController mInstance = null;
|
||||
|
||||
|
|
|
@ -47,84 +47,28 @@ import com.mapswithme.util.Utils;
|
|||
|
||||
public class MapInfoView extends LinearLayout
|
||||
{
|
||||
public interface OnVisibilityChangedListener
|
||||
{
|
||||
public void onHeadVisibilityChanged(boolean isVisible);
|
||||
|
||||
public void onBodyVisibilityChanged(boolean isVisible);
|
||||
}
|
||||
|
||||
private OnVisibilityChangedListener mVisibilityChangedListener;
|
||||
|
||||
public static enum State
|
||||
{
|
||||
COLLAPSED,
|
||||
HEAD,
|
||||
FULL
|
||||
}
|
||||
|
||||
private boolean mIsHeaderVisible = true;
|
||||
private boolean mIsBodyVisible = true;
|
||||
|
||||
private final ViewGroup mHeaderGroup;
|
||||
private final ViewGroup mBodyGroup;
|
||||
private final ViewGroup mHeaderGroup;
|
||||
private final ViewGroup mBodyGroup;
|
||||
private final ScrollView mBodyContainer;
|
||||
private final View mView;
|
||||
|
||||
private State mCurrentState = State.COLLAPSED;
|
||||
|
||||
private final View mView;
|
||||
// Header
|
||||
private final TextView mTitle;
|
||||
private final TextView mSubtitle;
|
||||
private final CheckBox mIsBookmarked;
|
||||
|
||||
// Data
|
||||
private MapObject mMapObject;
|
||||
|
||||
// Views
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
// Body
|
||||
private View mShareView;
|
||||
private View mEditBtn;
|
||||
private TextView mReturnToCallerBtn;
|
||||
|
||||
// Gestures
|
||||
private final GestureDetectorCompat mGestureDetector;
|
||||
private final OnGestureListener mGestureListener = new GestureDetector.SimpleOnGestureListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
|
||||
{
|
||||
final boolean isVertical = Math.abs(distanceY) > 2 * Math.abs(distanceX);
|
||||
final boolean isInRange = Math.abs(distanceY) > 1 && Math.abs(distanceY) < 100;
|
||||
|
||||
if (isVertical && isInRange)
|
||||
{
|
||||
|
||||
if (distanceY < 0)
|
||||
setState(State.HEAD);
|
||||
else
|
||||
setState(State.FULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e)
|
||||
{
|
||||
if (mCurrentState == State.FULL)
|
||||
setState(State.HEAD);
|
||||
else
|
||||
setState(State.FULL);
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
private OnVisibilityChangedListener mVisibilityChangedListener;
|
||||
private boolean mIsHeaderVisible = true;
|
||||
private boolean mIsBodyVisible = true;
|
||||
private State mCurrentState = State.COLLAPSED;
|
||||
// Data
|
||||
private MapObject mMapObject;
|
||||
private int mMaxBodyHeight = 0;
|
||||
private LinearLayout mGeoLayout = null;
|
||||
private View mDistanceView;
|
||||
private TextView mDistanceText;
|
||||
|
||||
public MapInfoView(Context context, AttributeSet attrs, int defStyleAttr)
|
||||
{
|
||||
|
@ -145,7 +89,7 @@ public class MapInfoView extends LinearLayout
|
|||
mIsBookmarked = (CheckBox) mHeaderGroup.findViewById(R.id.info_box_is_bookmarked);
|
||||
|
||||
// We don't want to use OnCheckedChangedListener because it gets called
|
||||
// if someone calls setCheched() from code. We need only user interaction.
|
||||
// if someone calls setChecked() from code. We need only user interaction.
|
||||
mIsBookmarked.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -161,9 +105,8 @@ public class MapInfoView extends LinearLayout
|
|||
}
|
||||
else
|
||||
{
|
||||
final Bookmark newbmk = bm.getBookmark(bm.addNewBookmark(
|
||||
mMapObject.getName(), mMapObject.getLat(), mMapObject.getLon()));
|
||||
setMapObject(newbmk);
|
||||
final Bookmark newBookmark = bm.getBookmark(bm.addNewBookmark(mMapObject.getName(), mMapObject.getLat(), mMapObject.getLon()));
|
||||
setMapObject(newBookmark);
|
||||
}
|
||||
Framework.invalidate();
|
||||
}
|
||||
|
@ -173,9 +116,44 @@ public class MapInfoView extends LinearLayout
|
|||
mBodyContainer = (ScrollView) mBodyGroup.findViewById(R.id.body_container);
|
||||
|
||||
// Gestures
|
||||
OnGestureListener mGestureListener = new GestureDetector.SimpleOnGestureListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
|
||||
{
|
||||
final boolean isVertical = Math.abs(distanceY) > 2 * Math.abs(distanceX);
|
||||
final boolean isInRange = Math.abs(distanceY) > 1 && Math.abs(distanceY) < 100;
|
||||
|
||||
if (isVertical && isInRange)
|
||||
{
|
||||
|
||||
if (distanceY < 0)
|
||||
setState(State.HEAD);
|
||||
else
|
||||
setState(State.FULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent e)
|
||||
{
|
||||
if (mCurrentState == State.FULL)
|
||||
setState(State.HEAD);
|
||||
else
|
||||
setState(State.FULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener);
|
||||
mView.setOnClickListener(new OnClickListener()
|
||||
{ @Override public void onClick(View v) { /* Friggin system does not work without this stub.*/ }});
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v) { /* Friggin system does not work without this stub.*/ }
|
||||
});
|
||||
}
|
||||
|
||||
public MapInfoView(Context context, AttributeSet attrs)
|
||||
|
@ -207,7 +185,9 @@ public class MapInfoView extends LinearLayout
|
|||
calculateMaxBodyHeight();
|
||||
|
||||
if (mIsBodyVisible == show)
|
||||
{
|
||||
return; // if state is already same as we need
|
||||
}
|
||||
|
||||
final long duration = 400;
|
||||
|
||||
|
@ -229,7 +209,9 @@ public class MapInfoView extends LinearLayout
|
|||
mView.startAnimation(slideUp);
|
||||
|
||||
if (mVisibilityChangedListener != null)
|
||||
mVisibilityChangedListener.onBodyVisibilityChanged(show);
|
||||
{
|
||||
mVisibilityChangedListener.onPPVisibilityChanged(show);
|
||||
}
|
||||
}
|
||||
else // slide down
|
||||
{
|
||||
|
@ -250,7 +232,9 @@ public class MapInfoView extends LinearLayout
|
|||
UiUtils.hide(mBodyGroup);
|
||||
|
||||
if (mVisibilityChangedListener != null)
|
||||
mVisibilityChangedListener.onBodyVisibilityChanged(show);
|
||||
{
|
||||
mVisibilityChangedListener.onPPVisibilityChanged(show);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -263,7 +247,9 @@ public class MapInfoView extends LinearLayout
|
|||
private void showHeader(final boolean show)
|
||||
{
|
||||
if (mIsHeaderVisible == show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final int duration = 200;
|
||||
|
||||
|
@ -283,7 +269,9 @@ public class MapInfoView extends LinearLayout
|
|||
public void onAnimationEnd(Animation animation)
|
||||
{
|
||||
if (mVisibilityChangedListener != null)
|
||||
mVisibilityChangedListener.onHeadVisibilityChanged(show);
|
||||
{
|
||||
mVisibilityChangedListener.onPPPVisibilityChanged(show);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -305,7 +293,7 @@ public class MapInfoView extends LinearLayout
|
|||
{
|
||||
UiUtils.hide(mHeaderGroup);
|
||||
if (mVisibilityChangedListener != null)
|
||||
mVisibilityChangedListener.onHeadVisibilityChanged(show);
|
||||
mVisibilityChangedListener.onPPPVisibilityChanged(show);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -328,6 +316,28 @@ public class MapInfoView extends LinearLayout
|
|||
return mCurrentState;
|
||||
}
|
||||
|
||||
public void setState(State state)
|
||||
{
|
||||
if (mCurrentState != state)
|
||||
{
|
||||
// Do some transitions
|
||||
if (mCurrentState == State.COLLAPSED && state == State.HEAD)
|
||||
showHeader(true);
|
||||
else if (mCurrentState == State.HEAD && state == State.FULL)
|
||||
showBody(true);
|
||||
else if (mCurrentState == State.HEAD && state == State.COLLAPSED)
|
||||
showHeader(false);
|
||||
else if (mCurrentState == State.FULL && state == State.HEAD)
|
||||
showBody(false);
|
||||
else if (mCurrentState == State.FULL && state == State.COLLAPSED)
|
||||
slideEverythingDown();
|
||||
else
|
||||
throw new IllegalStateException(String.format("Invalid transition %s - > %s", mCurrentState, state));
|
||||
|
||||
mCurrentState = state;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasThatObject(MapObject mo)
|
||||
{
|
||||
if (mo == null && mMapObject == null)
|
||||
|
@ -353,21 +363,21 @@ public class MapInfoView extends LinearLayout
|
|||
boolean isChecked = false;
|
||||
switch (mo.getType())
|
||||
{
|
||||
case POI:
|
||||
setBodyForPOI(mo);
|
||||
break;
|
||||
case BOOKMARK:
|
||||
isChecked = true;
|
||||
setBodyForBookmark((Bookmark) mo);
|
||||
break;
|
||||
case ADDITIONAL_LAYER:
|
||||
setBodyForAdditionalLayer((SearchResult) mo);
|
||||
break;
|
||||
case API_POINT:
|
||||
setBodyForAPI(mo);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown MapObject type:" + mo.getType());
|
||||
case POI:
|
||||
setBodyForPOI(mo);
|
||||
break;
|
||||
case BOOKMARK:
|
||||
isChecked = true;
|
||||
setBodyForBookmark((Bookmark) mo);
|
||||
break;
|
||||
case ADDITIONAL_LAYER:
|
||||
setBodyForAdditionalLayer((SearchResult) mo);
|
||||
break;
|
||||
case API_POINT:
|
||||
setBodyForAPI(mo);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown MapObject type:" + mo.getType());
|
||||
}
|
||||
|
||||
mIsBookmarked.setChecked(isChecked);
|
||||
|
@ -389,7 +399,7 @@ public class MapInfoView extends LinearLayout
|
|||
|
||||
private void setUpBottomButtons()
|
||||
{
|
||||
mShareView = mBodyGroup.findViewById(R.id.info_box_share);
|
||||
View mShareView = mBodyGroup.findViewById(R.id.info_box_share);
|
||||
mShareView.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -399,8 +409,8 @@ public class MapInfoView extends LinearLayout
|
|||
}
|
||||
});
|
||||
|
||||
mEditBtn = mBodyGroup.findViewById(R.id.info_box_edit);
|
||||
mReturnToCallerBtn = (TextView) mBodyGroup.findViewById(R.id.info_box_back_to_caller);
|
||||
View mEditBtn = mBodyGroup.findViewById(R.id.info_box_edit);
|
||||
TextView mReturnToCallerBtn = (TextView) mBodyGroup.findViewById(R.id.info_box_back_to_caller);
|
||||
UiUtils.hide(mEditBtn);
|
||||
UiUtils.hide(mReturnToCallerBtn);
|
||||
|
||||
|
@ -429,10 +439,10 @@ public class MapInfoView extends LinearLayout
|
|||
.format("%s {icon} %s", getResources().getString(R.string.more_info), r.getCallerName(getContext()));
|
||||
|
||||
final int spanStart = txtPattern.indexOf("{icon}");
|
||||
final int spanEnd = spanStart + "{icon}".length();
|
||||
final int spanEnd = spanStart + "{icon}".length();
|
||||
|
||||
final Drawable icon = r.getIcon(getContext());
|
||||
final int spanSize = (int) (25*getResources().getDisplayMetrics().density);
|
||||
final int spanSize = (int) (25 * getResources().getDisplayMetrics().density);
|
||||
icon.setBounds(0, 0, spanSize, spanSize);
|
||||
final ImageSpan callerIconSpan = new ImageSpan(icon, ImageSpan.ALIGN_BOTTOM);
|
||||
|
||||
|
@ -452,10 +462,6 @@ public class MapInfoView extends LinearLayout
|
|||
}
|
||||
}
|
||||
|
||||
private LinearLayout mGeoLayout = null;
|
||||
private View mDistanceView;
|
||||
private TextView mDistanceText;
|
||||
|
||||
private void setUpGeoInformation()
|
||||
{
|
||||
mGeoLayout = (LinearLayout) mBodyContainer.findViewById(R.id.info_box_geo_ref);
|
||||
|
@ -485,7 +491,7 @@ public class MapInfoView extends LinearLayout
|
|||
final String copyText = getResources().getString(android.R.string.copy);
|
||||
final String arrCoord[] = {
|
||||
UiUtils.formatLatLon(lat, lon),
|
||||
UiUtils.formatLatLonToDMS(lat, lon) };
|
||||
UiUtils.formatLatLonToDMS(lat, lon)};
|
||||
|
||||
menu.add(Menu.NONE, 0, 0, String.format("%s %s", copyText, arrCoord[0]));
|
||||
menu.add(Menu.NONE, 1, 1, String.format("%s %s", copyText, arrCoord[1]));
|
||||
|
@ -548,16 +554,18 @@ public class MapInfoView extends LinearLayout
|
|||
final View bmkView = mInflater.inflate(R.layout.info_box_bookmark, null);
|
||||
|
||||
// Description of BMK
|
||||
final WebView descritionWv = (WebView) bmkView.findViewById(R.id.info_box_bookmark_descr);
|
||||
final WebView descriptionWv = (WebView) bmkView.findViewById(R.id.info_box_bookmark_descr);
|
||||
final String descriptionTxt = bmk.getBookmarkDescription();
|
||||
|
||||
if (TextUtils.isEmpty(descriptionTxt))
|
||||
UiUtils.hide(descritionWv);
|
||||
{
|
||||
UiUtils.hide(descriptionWv);
|
||||
}
|
||||
else
|
||||
{
|
||||
descritionWv.loadData(descriptionTxt, "text/html; charset=UTF-8", null);
|
||||
descritionWv.setBackgroundColor(Color.TRANSPARENT);
|
||||
UiUtils.show(descritionWv);
|
||||
descriptionWv.loadData(descriptionTxt, "text/html; charset=UTF-8", null);
|
||||
descriptionWv.setBackgroundColor(Color.TRANSPARENT);
|
||||
UiUtils.show(descriptionWv);
|
||||
}
|
||||
|
||||
mBodyContainer.addView(bmkView);
|
||||
|
@ -609,7 +617,9 @@ public class MapInfoView extends LinearLayout
|
|||
public void onResume()
|
||||
{
|
||||
if (mMapObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
checkBookmarkWasDeleted();
|
||||
checkApiWasCanceled();
|
||||
|
@ -662,29 +672,7 @@ public class MapInfoView extends LinearLayout
|
|||
}
|
||||
}
|
||||
|
||||
public void setState(State state)
|
||||
{
|
||||
if (mCurrentState != state)
|
||||
{
|
||||
// Do some transitions
|
||||
if (mCurrentState == State.COLLAPSED && state == State.HEAD)
|
||||
showHeader(true);
|
||||
else if (mCurrentState == State.HEAD && state == State.FULL)
|
||||
showBody(true);
|
||||
else if (mCurrentState == State.HEAD && state == State.COLLAPSED)
|
||||
showHeader(false);
|
||||
else if (mCurrentState == State.FULL && state == State.HEAD)
|
||||
showBody(false);
|
||||
else if (mCurrentState == State.FULL && state == State.COLLAPSED)
|
||||
slideEverytingDown();
|
||||
else
|
||||
throw new IllegalStateException(String.format("Ivalid transition %s - > %s", mCurrentState, state));
|
||||
|
||||
mCurrentState = state;
|
||||
}
|
||||
}
|
||||
|
||||
private void slideEverytingDown()
|
||||
private void slideEverythingDown()
|
||||
{
|
||||
final TranslateAnimation slideDown = new TranslateAnimation(
|
||||
Animation.RELATIVE_TO_SELF, 0,
|
||||
|
@ -705,12 +693,26 @@ public class MapInfoView extends LinearLayout
|
|||
UiUtils.hide(mBodyGroup);
|
||||
if (mVisibilityChangedListener != null)
|
||||
{
|
||||
mVisibilityChangedListener.onHeadVisibilityChanged(false);
|
||||
mVisibilityChangedListener.onBodyVisibilityChanged(false);
|
||||
mVisibilityChangedListener.onPPPVisibilityChanged(false);
|
||||
mVisibilityChangedListener.onPPVisibilityChanged(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mView.startAnimation(slideDown);
|
||||
}
|
||||
|
||||
public static enum State
|
||||
{
|
||||
COLLAPSED,
|
||||
HEAD,
|
||||
FULL
|
||||
}
|
||||
|
||||
public interface OnVisibilityChangedListener
|
||||
{
|
||||
public void onPPPVisibilityChanged(boolean isVisible);
|
||||
|
||||
public void onPPVisibilityChanged(boolean isVisible);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue