[android] Public API for choosing location by using the app #2675

Closed
rtsisyk wants to merge 1 commit from rt-location-api into master
Owner
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("om://location"));
startActivityForResult(intent, REQ_CODE_LOCATION);

Closes #2674

```java Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("om://location")); startActivityForResult(intent, REQ_CODE_LOCATION); ``` Closes #2674
Author
Owner
https://user-images.githubusercontent.com/1799054/172048632-5b9f9549-5a95-491c-9efe-94c55cea7054.mp4
biodranik (Migrated from github.com) requested changes 2022-06-05 14:03:34 +00:00
@ -402,2 +407,4 @@
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
biodranik (Migrated from github.com) commented 2022-06-05 11:05:32 +00:00

А тут не надо if (launched as api and needs to return a result)?

А тут не надо if (launched as api and needs to return a result)?
biodranik (Migrated from github.com) commented 2022-06-05 11:10:40 +00:00

Вообще это точно правильная точка входа для всех вызовов апи?

Вообще это точно правильная точка входа для всех вызовов апи?
biodranik (Migrated from github.com) commented 2022-06-05 12:49:11 +00:00
            final Intent apiResult = new Intent();
            final double[] center = Framework.nativeGetScreenRectCenter();
```suggestion final Intent apiResult = new Intent(); final double[] center = Framework.nativeGetScreenRectCenter(); ```
biodranik (Migrated from github.com) commented 2022-06-05 13:45:08 +00:00

А отмену как будут проверять? На != RESULT_OK?

А отмену как будут проверять? На != RESULT_OK?
biodranik (Migrated from github.com) commented 2022-06-05 13:47:17 +00:00

Наверное это лучше перед finish сделать, внутри finish тоже могут if попасться.

Наверное это лучше перед finish сделать, внутри finish тоже могут if попасться.
@ -32,3 +32,4 @@
private static final long DELAY = 100;
private boolean mCanceled = false;
biodranik (Migrated from github.com) commented 2022-06-05 13:48:53 +00:00

Зачем? Я так понял, AppCompatActivity использовался для переключения тем на старых версиях андроида. Или тут он не критичен? Что будет в дарк моде?

Зачем? Я так понял, AppCompatActivity использовался для переключения тем на старых версиях андроида. Или тут он не критичен? Что будет в дарк моде?
@ -199,0 +214,4 @@
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
biodranik (Migrated from github.com) commented 2022-06-05 13:50:34 +00:00

Это проверка, что аппа была запущена пользователем по тычку в ярлык? А если пользователь вернулся в ранее открытое приложение, там тоже будет CATEGORY_LAUNCHER?

Это проверка, что аппа была запущена пользователем по тычку в ярлык? А если пользователь вернулся в ранее открытое приложение, там тоже будет CATEGORY_LAUNCHER?
@ -24,2 +22,4 @@
//public static final int TYPE_SUBSCRIPTION = 7;
public static final int TYPE_LOCATION = 8;
private final int mUrlType;
biodranik (Migrated from github.com) commented 2022-06-05 13:51:20 +00:00

Выпиливай сразу и тут и в C++

Выпиливай сразу и тут и в C++
@ -0,0 +9,4 @@
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
biodranik (Migrated from github.com) commented 2022-06-05 13:55:09 +00:00

Это кто создаёт? Коммент.

Это кто создаёт? Коммент.
@ -0,0 +10,4 @@
.DS_Store
/build
/captures
.externalNativeBuild
biodranik (Migrated from github.com) commented 2022-06-05 13:54:11 +00:00

Почему с точкой? Кто так создаёт?

Почему с точкой? Кто так создаёт?
@ -0,0 +11,4 @@
/build
/captures
.externalNativeBuild
.cxx
biodranik (Migrated from github.com) commented 2022-06-05 13:54:17 +00:00

Wtf?

Wtf?
@ -0,0 +12,4 @@
/captures
.externalNativeBuild
.cxx
local.properties
biodranik (Migrated from github.com) commented 2022-06-05 13:54:02 +00:00

Выше уже есть же.

Выше уже есть же.
@ -0,0 +1 @@
/build
biodranik (Migrated from github.com) commented 2022-06-05 13:53:52 +00:00

Почему у тебя тут папка создалась? Кем? Раньше не создавалась.

Почему у тебя тут папка создалась? Кем? Раньше не создавалась.
@ -0,0 +1,33 @@
plugins {
id 'com.android.application'
biodranik (Migrated from github.com) commented 2022-06-05 13:58:49 +00:00

example should be in this repo: https://github.com/organicmaps/api-android

example should be in this repo: https://github.com/organicmaps/api-android
biodranik (Migrated from github.com) commented 2022-06-05 13:59:07 +00:00
But please fix there https://github.com/organicmaps/api-android/pull/1 first
@ -0,0 +20,4 @@
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
biodranik (Migrated from github.com) commented 2022-06-05 13:58:17 +00:00

1_11

1_11
@ -0,0 +29,4 @@
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
biodranik (Migrated from github.com) commented 2022-06-05 13:59:51 +00:00

Это используется?

Это используется?
@ -0,0 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
biodranik (Migrated from github.com) commented 2022-06-05 14:00:46 +00:00

А зачем либу?

А зачем либу?
@ -92,6 +92,8 @@ ParsedMapApi::UrlType GetUrlType(url::Url const & url)
return ParsedMapApi::UrlType::Route;
if (type == "search")
return ParsedMapApi::UrlType::Search;
if (type == "location")
biodranik (Migrated from github.com) commented 2022-06-05 14:02:35 +00:00

Название неудачное, наверняка понадобится отдельное api для получения текущей позиции пользователя. Лучше назвать coordinates, и предусмотреть больше одного возвращаемого значения, плюс к каждому значению доп. инфу, как минимум имя.

Название неудачное, наверняка понадобится отдельное api для получения текущей позиции пользователя. Лучше назвать coordinates, и предусмотреть больше одного возвращаемого значения, плюс к каждому значению доп. инфу, как минимум имя.
biodranik (Migrated from github.com) commented 2022-06-05 14:02:52 +00:00

Скобки не нужны

Скобки не нужны
@ -57,3 +61,4 @@
Location = 8,
};
struct ParsingResult
biodranik (Migrated from github.com) commented 2022-06-05 14:03:29 +00:00

Выпилить то, что выше, сделать Coordinates = 4, Location = 5 на будущее, для GPS координат пользователя.

Выпилить то, что выше, сделать Coordinates = 4, Location = 5 на будущее, для GPS координат пользователя.
rtsisyk reviewed 2022-06-05 18:13:06 +00:00
Author
Owner

Есть какое-то научное подтверждение необходимости написания final в каждой строчке? Если хочется immutable, то есть другие языки программирования для этого.

Есть какое-то научное подтверждение необходимости написания final в каждой строчке? Если хочется immutable, то есть другие языки программирования для этого.
rtsisyk reviewed 2022-06-05 18:13:31 +00:00
rtsisyk reviewed 2022-06-05 18:14:22 +00:00
@ -32,3 +32,4 @@
private static final long DELAY = 100;
private boolean mCanceled = false;
Author
Owner

Попробую вернуть назад. Там какое-то deprecated вылезает на startAcitvityForResult, хотя в основном классе это никто не запрещал.

Попробую вернуть назад. Там какое-то deprecated вылезает на startAcitvityForResult, хотя в основном классе это никто не запрещал.
rtsisyk reviewed 2022-06-05 18:14:28 +00:00
@ -0,0 +29,4 @@
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Author
Owner

Удалю

Удалю
rtsisyk reviewed 2022-06-05 18:14:45 +00:00
@ -0,0 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
Author
Owner

По умолчанию так генерится.

По умолчанию так генерится.
rtsisyk reviewed 2022-06-05 18:15:08 +00:00
@ -57,3 +61,4 @@
Location = 8,
};
struct ParsingResult
Author
Owner

Это сломает совместимость, наверное?

Это сломает совместимость, наверное?
vng (Migrated from github.com) reviewed 2022-06-06 09:56:24 +00:00
vng (Migrated from github.com) commented 2022-06-06 09:46:18 +00:00
  • No need to break here?
  • Why not to write simple "if" instead of "switch"?
- No need to break here? - Why not to write simple "if" instead of "switch"?
vng (Migrated from github.com) commented 2022-06-06 09:50:29 +00:00

Есть ли смысл заморочится чтобы не было копипаста в DownloaderActivity, SplashActivity, ... ?

Есть ли смысл заморочится чтобы не было копипаста в DownloaderActivity, SplashActivity, ... ?
@ -0,0 +51,4 @@
double lon = data.getDoubleExtra("lon", 0.0);
String message = String.format(Locale.ENGLISH, "Result: lat=%.4f lon=%.4f", lat, lon);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
break;
vng (Migrated from github.com) commented 2022-06-06 09:54:19 +00:00

Хм, выше в вроде бы в такой же ситуации break не было и вызывался super.onActivity ...

Хм, выше в _вроде бы_ в такой же ситуации break не было и вызывался super.onActivity ...
biodranik commented 2022-06-13 21:59:32 +00:00 (Migrated from github.com)

@rtsisyk поправишь?

@rtsisyk поправишь?
Author
Owner

Closing in favor of organicmaps/organicmaps#2907

Closing in favor of https://git.omaps.dev/organicmaps/organicmaps/pulls/2907
rtsisyk reviewed 2022-07-03 12:01:30 +00:00
@ -32,3 +32,4 @@
private static final long DELAY = 100;
private boolean mCanceled = false;
Author
Owner

Вернул назад. Показывает, что deprecated. Предлагаемое решение от гугла выглядит слишком сложным.

Вернул назад. Показывает, что deprecated. Предлагаемое решение от гугла выглядит слишком сложным.
rtsisyk reviewed 2022-07-03 12:01:57 +00:00
@ -57,3 +61,4 @@
Location = 8,
};
struct ParsingResult
Author
Owner

Здесь в итоге ничего не стал добавлять, ограничился существующими вариантами.

Здесь в итоге ничего не стал добавлять, ограничился существующими вариантами.
rtsisyk reviewed 2022-07-03 12:02:31 +00:00
Author
Owner

Да в целом можно всегда этот setResult звать без каких либо последствий. Будет 1 строчка, а не 5.

Да в целом можно всегда этот setResult звать без каких либо последствий. Будет 1 строчка, а не 5.
rtsisyk reviewed 2022-07-03 12:02:42 +00:00
@ -0,0 +51,4 @@
double lon = data.getDoubleExtra("lon", 0.0);
String message = String.format(Locale.ENGLISH, "Result: lat=%.4f lon=%.4f", lat, lon);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
break;
Author
Owner

Этот код убит.

Этот код убит.
rtsisyk reviewed 2022-07-03 12:02:53 +00:00
Author
Owner

Этого кода больше нет.

Этого кода больше нет.
rtsisyk reviewed 2022-07-03 12:03:04 +00:00
@ -92,6 +92,8 @@ ParsedMapApi::UrlType GetUrlType(url::Url const & url)
return ParsedMapApi::UrlType::Route;
if (type == "search")
return ParsedMapApi::UrlType::Search;
if (type == "location")
Author
Owner

Этого больше нет.

Этого больше нет.
This repo is archived. You cannot comment on pull requests.
No reviewers
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#2675
No description provided.