Search in sources :

Example 1 with ProximitySheet

use of org.telegram.ui.Components.ProximitySheet in project Telegram-FOSS by Telegram-FOSS-Team.

the class LocationActivity method openProximityAlert.

private void openProximityAlert() {
    if (proximityCircle == null) {
        createCircle(500);
        proximityCircleRadius = 500;
    } else {
        previousRadius = proximityCircleRadius;
    }
    TLRPC.User user;
    if (DialogObject.isUserDialog(dialogId)) {
        user = getMessagesController().getUser(dialogId);
    } else {
        user = null;
    }
    proximitySheet = new ProximitySheet(getParentActivity(), user, (move, radius) -> {
        if (proximityCircle != null) {
            proximityCircleRadius = radius;
            proximityCircle.setPoints(Polygon.pointsAsCircle(proximityCircleCenter, radius));
            if (move) {
                moveToBounds(radius, true, true);
            }
        }
        if (DialogObject.isChatDialog(dialogId)) {
            return true;
        }
        for (int a = 0, N = markers.size(); a < N; a++) {
            LiveLocation location = markers.get(a);
            if (location.object == null || UserObject.isUserSelf(location.user)) {
                continue;
            }
            TLRPC.GeoPoint point = location.object.media.geo;
            Location loc = new Location("network");
            loc.setLatitude(point.lat);
            loc.setLongitude(point._long);
            if (myLocation.distanceTo(loc) > radius) {
                return true;
            }
        }
        return false;
    }, (move, radius) -> {
        LocationController.SharingLocationInfo info = getLocationController().getSharingLocationInfo(dialogId);
        if (info == null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("ShareLocationAlertTitle", R.string.ShareLocationAlertTitle));
            builder.setMessage(LocaleController.getString("ShareLocationAlertText", R.string.ShareLocationAlertText));
            builder.setPositiveButton(LocaleController.getString("ShareLocationAlertButton", R.string.ShareLocationAlertButton), (dialog, id) -> shareLiveLocation(user, 900, radius));
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
            return false;
        }
        proximitySheet.setRadiusSet();
        proximityButton.setImageResource(R.drawable.msg_location_alert2);
        getUndoView().showWithAction(0, UndoView.ACTION_PROXIMITY_SET, radius, user, null, null);
        getLocationController().setProximityLocation(dialogId, radius, true);
        return true;
    }, () -> {
        if (mapView != null) {
            mapView.setPadding(AndroidUtilities.dp(70), 0, AndroidUtilities.dp(70), AndroidUtilities.dp(10));
        }
        if (!proximitySheet.getRadiusSet()) {
            if (previousRadius > 0) {
                proximityCircleRadius = previousRadius;
                proximityCircle.setPoints(Polygon.pointsAsCircle(proximityCircleCenter, previousRadius));
            } else if (proximityCircle != null) {
                mapView.getOverlayManager().remove(proximityCircle);
                proximityCircle = null;
            }
        }
        proximitySheet = null;
    });
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.addView(proximitySheet, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    proximitySheet.show();
}
Also used : ProximitySheet(org.telegram.ui.Components.ProximitySheet) Arrays(java.util.Arrays) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) LocationController(org.telegram.messenger.LocationController) EditTextBoldCursor(org.telegram.ui.Components.EditTextBoldCursor) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) Manifest(android.Manifest) StateListAnimator(android.animation.StateListAnimator) ITileSource(org.osmdroid.tileprovider.tilesource.ITileSource) Shader(android.graphics.Shader) Canvas(android.graphics.Canvas) XYTileSource(org.osmdroid.tileprovider.tilesource.XYTileSource) Configuration(org.osmdroid.config.Configuration) LocationActivitySearchAdapter(org.telegram.ui.Adapters.LocationActivitySearchAdapter) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ScrollEvent(org.osmdroid.events.ScrollEvent) UndoView(org.telegram.ui.Components.UndoView) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Polygon(org.osmdroid.views.overlay.Polygon) NotificationCenter(org.telegram.messenger.NotificationCenter) Outline(android.graphics.Outline) LocationActivityAdapter(org.telegram.ui.Adapters.LocationActivityAdapter) Html(android.text.Html) HintView(org.telegram.ui.Components.HintView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) FileLoader(org.telegram.messenger.FileLoader) ZoomEvent(org.osmdroid.events.ZoomEvent) BitmapFactory(android.graphics.BitmapFactory) AlertsCreator(org.telegram.ui.Components.AlertsCreator) ArrayList(java.util.ArrayList) TileSourceFactory(org.osmdroid.tileprovider.tilesource.TileSourceFactory) TLRPC(org.telegram.tgnet.TLRPC) Toast(android.widget.Toast) BuildConfig(org.telegram.messenger.BuildConfig) ActionBarMenu(org.telegram.ui.ActionBar.ActionBarMenu) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) MapView(org.osmdroid.views.MapView) File(java.io.File) Gravity(android.view.Gravity) UserObject(org.telegram.messenger.UserObject) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) LocationCell(org.telegram.ui.Cells.LocationCell) ChatObject(org.telegram.messenger.ChatObject) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) EditText(android.widget.EditText) ValueAnimator(android.animation.ValueAnimator) IMyLocationProvider(org.osmdroid.views.overlay.mylocation.IMyLocationProvider) ThemeDescription(org.telegram.ui.ActionBar.ThemeDescription) Rect(android.graphics.Rect) MyLocationNewOverlay(org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay) LinearLayout(android.widget.LinearLayout) ActionBarMenuItem(org.telegram.ui.ActionBar.ActionBarMenuItem) PackageManager(android.content.pm.PackageManager) AndroidUtilities(org.telegram.messenger.AndroidUtilities) CubicBezierInterpolator(org.telegram.ui.Components.CubicBezierInterpolator) Animator(android.animation.Animator) LinkMovementMethod(android.text.method.LinkMovementMethod) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ApplicationLoader(org.telegram.messenger.ApplicationLoader) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) Locale(java.util.Locale) View(android.view.View) IMapController(org.osmdroid.api.IMapController) RecyclerView(androidx.recyclerview.widget.RecyclerView) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) BitmapShader(android.graphics.BitmapShader) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) IGeoPoint(org.osmdroid.api.IGeoPoint) GpsMyLocationProvider(org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) ObjectAnimator(android.animation.ObjectAnimator) ImageLocation(org.telegram.messenger.ImageLocation) Marker(org.osmdroid.views.overlay.Marker) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) BitmapDrawable(android.graphics.drawable.BitmapDrawable) PorterDuff(android.graphics.PorterDuff) MapPlaceholderDrawable(org.telegram.ui.Components.MapPlaceholderDrawable) ViewGroup(android.view.ViewGroup) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) List(java.util.List) TextView(android.widget.TextView) Location(android.location.Location) ProximitySheet(org.telegram.ui.Components.ProximitySheet) LocationManager(android.location.LocationManager) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) ViewOutlineProvider(android.view.ViewOutlineProvider) Intent(android.content.Intent) LocaleController(org.telegram.messenger.LocaleController) HashMap(java.util.HashMap) HeaderCell(org.telegram.ui.Cells.HeaderCell) GeoPoint(org.osmdroid.util.GeoPoint) SuppressLint(android.annotation.SuppressLint) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) MapListener(org.osmdroid.events.MapListener) MotionEvent(android.view.MotionEvent) ActionBar(org.telegram.ui.ActionBar.ActionBar) AnimatorSet(android.animation.AnimatorSet) MessageObject(org.telegram.messenger.MessageObject) Build(android.os.Build) Projection(org.osmdroid.views.Projection) LongSparseArray(androidx.collection.LongSparseArray) DialogObject(org.telegram.messenger.DialogObject) BackupImageView(org.telegram.ui.Components.BackupImageView) Point(android.graphics.Point) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) BoundingBox(org.osmdroid.util.BoundingBox) MessagesController(org.telegram.messenger.MessagesController) Color(android.graphics.Color) Bitmap(android.graphics.Bitmap) OvershootInterpolator(android.view.animation.OvershootInterpolator) Activity(android.app.Activity) RecyclerListView(org.telegram.ui.Components.RecyclerListView) AlertDialog(org.telegram.ui.ActionBar.AlertDialog) IGeoPoint(org.osmdroid.api.IGeoPoint) GeoPoint(org.osmdroid.util.GeoPoint) FrameLayout(android.widget.FrameLayout) TLRPC(org.telegram.tgnet.TLRPC) ImageLocation(org.telegram.messenger.ImageLocation) Location(android.location.Location)

Aggregations

Manifest (android.Manifest)1 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 StateListAnimator (android.animation.StateListAnimator)1 ValueAnimator (android.animation.ValueAnimator)1 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 PackageManager (android.content.pm.PackageManager)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 BitmapShader (android.graphics.BitmapShader)1 Canvas (android.graphics.Canvas)1 Color (android.graphics.Color)1 Matrix (android.graphics.Matrix)1 Outline (android.graphics.Outline)1