Skip to content

Commit

Permalink
Merge pull request #3777 from FloEdelmann/links
Browse files Browse the repository at this point in the history
Add two achievement links, add debug link activity
  • Loading branch information
westnordost committed Feb 22, 2022
2 parents 946aabe + 5f9cfe1 commit 4cf48d2
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 46 deletions.
29 changes: 15 additions & 14 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="de.westnordost.streetcomplete"
android:installLocation="auto"
>
android:installLocation="auto">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand All @@ -13,7 +12,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<uses-feature android:name="android.hardware.screen.portrait"/>
<uses-feature android:name="android.hardware.screen.portrait" />

<!-- measuring distances with ARCore -->
<uses-permission android:name="android.permission.CAMERA" />
Expand All @@ -23,8 +22,8 @@
<queries>
<!-- open location in another app -->
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="geo"/>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="geo" />
</intent>
</queries>

Expand Down Expand Up @@ -67,23 +66,25 @@
android:name=".measure.MeasureActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity"/>
<activity android:name=".FragmentContainerActivity"/>
<activity android:name=".about.AboutActivity"/>
<activity android:name=".settings.ShowQuestFormsActivity"
android:configChanges="orientation|screenSize|uiMode"/>
tools:ignore="LockedOrientationActivity" />
<activity android:name=".FragmentContainerActivity" />
<activity android:name=".about.AboutActivity" />
<activity
android:name=".settings.ShowQuestFormsActivity"
android:configChanges="orientation|screenSize|uiMode" />
<activity
android:name=".settings.ShowLinksActivity"
android:configChanges="orientation|screenSize|uiMode" />
<activity
android:name=".user.UserActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<service
android:name=".data.download.DownloadService"
android:foregroundServiceType="dataSync"
/>
android:foregroundServiceType="dataSync" />
<service
android:name=".data.upload.UploadService"
android:foregroundServiceType="dataSync"
/>
android:foregroundServiceType="dataSync" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="@string/fileprovider_authority"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ private val links = listOf(
R.drawable.ic_link_organic_maps,
R.string.link_organic_maps_description
),
Link(
"osmand",
"https://osmand.net/",
"OsmAnd",
LinkCategory.MAPS,
R.drawable.ic_link_osmand,
R.string.link_osmand_description
),
Link(
"cyclosm",
"https://www.cyclosm.org",
Expand Down Expand Up @@ -250,6 +258,14 @@ private val links = listOf(
R.drawable.ic_link_osmhydrant,
R.string.link_osmhydrant_description
),
Link(
"sunders",
"https://sunders.uber.space/",
"Surveillance under Surveillance",
LinkCategory.MAPS,
R.drawable.ic_link_sunders,
R.string.link_sunders_description
),

/* -------------------------------------- Showcase ---------------------------------------*/
Link(
Expand Down Expand Up @@ -578,7 +594,9 @@ private val achievements = listOf(
1 to links("openstreetbrowser"),
2 to links("qwant_maps"),
3 to links("organic_maps"),
4 to links("indoorequal")
4 to links("indoorequal"),
5 to links("osmand"),
6 to links("sunders"),
)
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class SettingsFragment :
true
}

findPreference<Preference>("debug.links")?.setOnPreferenceClickListener {
startActivity(Intent(context, ShowLinksActivity::class.java))
true
}

findPreference<Preference>("debug.ar_measure_horizontal")?.setOnPreferenceClickListener {
startActivity(MeasureActivity.createIntent(requireContext(), false))
true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package de.westnordost.streetcomplete.settings

import android.content.Intent
import android.os.Bundle
import androidx.core.net.toUri
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import de.westnordost.streetcomplete.BaseActivity
import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.user.achievements.Link
import de.westnordost.streetcomplete.databinding.FragmentShowLinksBinding
import de.westnordost.streetcomplete.ktx.viewBinding
import de.westnordost.streetcomplete.user.GroupedLinksAdapter
import org.koin.android.ext.android.inject
import org.koin.core.qualifier.named

/** activity only used in debug, to show all achievement links */
class ShowLinksActivity : BaseActivity() {
private val links: List<Link> by inject(named("Links"))
private val binding by viewBinding(FragmentShowLinksBinding::inflate)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.fragment_show_links)
binding.toolbarLayout.toolbar.navigationIcon = getDrawable(R.drawable.ic_close_24dp)
binding.toolbarLayout.toolbar.setNavigationOnClickListener { onBackPressed() }
binding.toolbarLayout.toolbar.title = "Show Achievement Links"

binding.linksList.apply {
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
layoutManager = LinearLayoutManager(context)
adapter = GroupedLinksAdapter(links, ::openUrl)
}
}

private fun openUrl(url: String) {
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
startActivity(intent)
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_link_osmand.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="192dp"
android:height="192dp"
android:viewportWidth="192"
android:viewportHeight="192">
<path
android:pathData="M168,96C168,125.833 149.856,151.429 124,162.353C110.634,168 106,171 102,179C101.611,179.779 101.278,180.52 100.969,181.208C99.691,184.055 98.818,186 96,186C93.182,186 92.309,184.055 91.031,181.208C90.722,180.52 90.39,179.779 90,179C86,171 81,168 68,162.353C42.145,151.429 24,125.833 24,96C24,56.236 56.236,24 96,24C135.765,24 168,56.236 168,96ZM136,96C136,118.091 118.091,136 96,136C73.909,136 56,118.091 56,96C56,73.909 73.909,56 96,56C118.091,56 136,73.909 136,96Z"
android:fillColor="#FF8800"
android:fillType="evenOdd"/>
</vector>
32 changes: 32 additions & 0 deletions app/src/main/res/layout/fragment_show_links.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<include android:id="@+id/toolbarLayout"
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</FrameLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/linksList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="vertical"
tools:listitem="@layout/card_link_item"
android:clipToPadding="false" />

</LinearLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,10 @@ Unfortunately, due to a Google Play Store policy, no links leading to donations
<string name="link_openstreetbrowser_description">A map to browse OpenStreetMap map features by category</string>
<string name="link_qwant_maps_description">A map with searchable places and directions</string>
<string name="link_organic_maps_description">Maps app for travelers, hikers and cyclists that works offline</string>
<string name="link_osmand_description">Mobile app for online and offline map viewing and navigation</string>
<string name="link_weeklyosm_description">The weekly news blog about what’s happening in the OpenStreetMap world</string>
<string name="link_figuregrounder_description">Create figure-ground diagram posters of a city or neighbourhood</string>
<string name="link_sunders_description">A map of cameras and surveillance equipment</string>

<string name="achievement_first_edit_title">First Quest Solved</string>
<string name="achievement_first_edit_description">Welcome to the OpenStreetMap community! In your profile screen, you can see more info for each quest type you solved.</string>
Expand Down
51 changes: 20 additions & 31 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
android:defaultValue="ON"
android:entries="@array/pref_entries_autosync"
android:entryValues="@array/pref_entryvalues_autosync"
android:persistent="true"
/>
android:persistent="true" />

</PreferenceCategory>

Expand All @@ -34,22 +33,19 @@
android:defaultValue="DEFAULT"
android:entries="@array/pref_entries_resurvey_intervals"
android:entryValues="@array/pref_entryvalues_resurvey_intervals"
android:persistent="true"
/>
android:persistent="true" />

<SwitchPreference
android:key="display.nonQuestionNotes"
android:title="@string/pref_title_show_notes_not_phrased_as_questions"
android:summaryOn="@string/pref_summaryOn_show_notes_not_phrased_as_questions"
android:summaryOff="@string/pref_summaryOff_show_notes_not_phrased_as_questions"
android:persistent="true"
/>
android:persistent="true" />

<SwitchPreference
android:key="display.keepScreenOn"
android:title="@string/pref_title_keep_screen_on"
android:persistent="true"
/>
android:persistent="true" />

<ListPreference
android:key="theme.select"
Expand All @@ -58,45 +54,38 @@
android:defaultValue="AUTO"
android:entries="@array/pref_entries_theme_select"
android:entryValues="@array/pref_entryvalues_theme_select"
android:persistent="true"
/>
android:persistent="true" />

<ListPreference
android:key="language.select"
android:title="@string/pref_title_language_select"
android:summary="%s"
android:defaultValue=""
android:persistent="true"
/>
android:persistent="true" />

<!--
<ListPreference
<!-- <ListPreference
android:key="theme.background_type"
android:title="@string/pref_background_type_select"
app:useSimpleSummaryProvider="true"
android:defaultValue="MAP"
android:entries="@array/pref_entries_background_type_select"
android:entryValues="@array/pref_entryvalues_background_type_select"
android:persistent="true"
/>
-->
android:persistent="true" /> -->

</PreferenceCategory>

<PreferenceCategory
android:key="advanced"
android:title="@string/pref_category_advanced"
>
android:title="@string/pref_category_advanced">

<Preference
android:key="delete_cache"
android:title="@string/pref_title_delete_cache"
android:summary="@string/pref_title_delete_cache_summary"
/>
android:summary="@string/pref_title_delete_cache_summary" />

<Preference
android:key="quests.restore.hidden"
android:title="@string/pref_title_quests_restore_hidden"
/>
android:title="@string/pref_title_quests_restore_hidden" />

<de.westnordost.streetcomplete.settings.NumberPickerPreference
android:key="map.tilecache"
Expand All @@ -110,8 +99,7 @@
android:dialogMessage="@string/pref_tilecache_size_message"
android:dialogLayout="@layout/dialog_number_picker_preference"
android:positiveButtonText="@android:string/ok"
android:negativeButtonText="@android:string/cancel"
/>
android:negativeButtonText="@android:string/cancel" />

</PreferenceCategory>

Expand All @@ -121,18 +109,19 @@

<Preference
android:key="debug.quests"
android:title="Show Quest Forms"
/>
android:title="Show Quest Forms" />

<Preference
android:key="debug.links"
android:title="Show Achievement Links" />

<Preference
android:key="debug.ar_measure_horizontal"
android:title="AR Measure Horizontal"
/>
android:title="AR Measure Horizontal" />

<Preference
android:key="debug.ar_measure_vertical"
android:title="AR Measure Vertical"
/>
android:title="AR Measure Vertical" />

</PreferenceCategory>

Expand Down

0 comments on commit 4cf48d2

Please sign in to comment.