Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The implementation of the location pinning app #2

Merged
merged 35 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7b5737c
Initial commit
shubertm Jul 17, 2022
7685b47
Initial commit
shubertm Jul 17, 2022
4d776df
Initial commit
shubertm Jul 22, 2022
be4d6f6
Create build.yml
shubertm Jul 23, 2022
ddf6d74
Update build.yml
shubertm Jul 23, 2022
4334697
Update build.yml
shubertm Jul 23, 2022
e2582a1
Update build.yml
shubertm Jul 23, 2022
4e4e60a
Update build.yml
shubertm Jul 23, 2022
df6de0f
Update execute permission for gradlew command.
shubertm Jul 23, 2022
da0cfce
Merge remote-tracking branch 'origin/main'
shubertm Jul 23, 2022
e2b9c1b
Second commit
shubertm Jul 25, 2022
cf57f4e
Create build.yml
shubertm Jul 23, 2022
e31a68d
Update build.yml
shubertm Jul 23, 2022
ff79c8c
Update build.yml
shubertm Jul 23, 2022
149effc
Update build.yml
shubertm Jul 23, 2022
2793f62
Update build.yml
shubertm Jul 23, 2022
ddc322c
Second commit
shubertm Jul 25, 2022
e89c8a8
Second commit
shubertm Jul 25, 2022
f8de808
Second commit
shubertm Jul 25, 2022
97caaa7
Merge remote-tracking branch 'origin/main'
shubertm Jul 25, 2022
683a1db
Second commit
shubertm Jul 26, 2022
af8a15a
Second commit
shubertm Jul 26, 2022
821e7ce
Third commit
shubertm Aug 4, 2022
fd3c888
Update build.yml
shubertm Aug 4, 2022
12a22d1
Parsing google maps short links
shubertm Aug 9, 2022
d6d52b7
Merge remote-tracking branch 'origin/main'
shubertm Aug 9, 2022
a4fc63b
Improve parsing links to get coordinates
shubertm Aug 14, 2022
c169b3b
Viewing coordinates
shubertm Aug 18, 2022
ca5a0f7
Delete .idea directory
shubertm Aug 22, 2022
efad718
Resolve some issues
shubertm Aug 23, 2022
18a1758
Merge remote-tracking branch 'origin/main'
shubertm Aug 23, 2022
b7666ba
Delete .idea directory
shubertm Aug 23, 2022
e8b6b5a
Resolve some issues
shubertm Aug 23, 2022
8282165
Merge remote-tracking branch 'origin/main'
shubertm Aug 23, 2022
74b1799
Resolve some issues
shubertm Aug 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build the app

on: [push]

jobs:
build:
runs-on: ubuntu-latest
environment: Development
env:
ACRA_LOGIN: ${{ secrets.ACRARIUM_BASIC_AUTH_LOGIN }}
ACRA_PASS: ${{ secrets.ACRARIUM_BASIC_AUTH_PASSWORD }}
ACRA_URI: ${{ secrets.ACRARIUM_URI }}
steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Build Debug APK
run: ./gradlew assembleDebug

- name: Upload Debug APK
uses: actions/upload-artifact@v2
with:
name: debug-apk
path: ./app/build/outputs/apk/debug/app-debug.apk

- name: Upload Release APK
uses: actions/upload-artifact@v2
with:
name: release-apk
path: ./app/build/outputs/apk/release/app-release.apk
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
kirillt marked this conversation as resolved.
Show resolved Hide resolved
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
kirillt marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
75 changes: 75 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
}

android {
compileSdk 32

defaultConfig {
applicationId "com.ark.globe"
minSdk 26
targetSdk 32
versionCode 1
versionName "1.0"
def login = System.getenv("ACRA_LOGIN") ?: ""
def password = System.getenv("ACRA_PASS") ?: ""
def uri = System.getenv("ACRA_URI") ?: ""
buildConfigField "String", "ACRA_LOGIN", "\"$login\""
buildConfigField "String", "ACRA_PASS", "\"$password\""
buildConfigField "String", "ACRA_URI", "\"$uri\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11

}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'androidx.room:room-runtime:2.4.2'
implementation 'androidx.room:room-ktx:2.4.2'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation 'com.android.volley:volley:1.2.1'

implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

implementation 'ch.acra:acra-http:5.9.5'
implementation 'ch.acra:acra-dialog:5.9.5'

implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.github.ark-builders:ark-filepicker:main-SNAPSHOT'
implementation 'androidx.preference:preference-ktx:1.2.0'
kapt 'androidx.room:room-compiler:2.4.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class nameText to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file nameText.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.ark.globe

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.ark.globe", appContext.packageName)
}
}
35 changes: 35 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.ark.globe">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name="com.ark.globe.App"
android:label="@string/app_name"
android:icon="@mipmap/ark_globe"
android:roundIcon="@mipmap/ark_globe_round"
android:requestLegacyExternalStorage="true"
android:theme="@style/Theme.ARK.Globe">
<activity
android:name="com.ark.globe.activities.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
</application>
</manifest>
Binary file added app/src/main/ark_globe-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions app/src/main/kotlin/com/ark/globe/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.ark.globe

import android.app.Application
import android.content.Context
import org.acra.config.dialog
import org.acra.config.httpSender
import org.acra.data.StringFormat
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender

class App: Application() {

override fun attachBaseContext(baseContext: Context){
super.attachBaseContext(baseContext)
initAcra {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.JSON

dialog{
text = getString(R.string.crash_dialog_desc)
title = getString(R.string.crash_dialog_title)
commentPrompt = getString(R.string.crash_dialog_comment)
}

httpSender {
uri = BuildConfig.ACRA_URI
basicAuthLogin = BuildConfig.ACRA_LOGIN
basicAuthPassword = BuildConfig.ACRA_PASS
httpMethod = HttpSender.Method.POST
}
}
}

}
97 changes: 97 additions & 0 deletions app/src/main/kotlin/com/ark/globe/activities/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.ark.globe.activities

import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.ark.globe.R
import com.ark.globe.contracts.PermissionContract
import com.ark.globe.databinding.ActivityMainBinding
import com.ark.globe.filehandling.FilePicker
import com.ark.globe.fragments.Settings
import com.ark.globe.fragments.locations.LocationsFragment
import com.ark.globe.preferences.GlobePreferences
import space.taran.arkfilepicker.onArkPathPicked

class MainActivity: AppCompatActivity() {

private lateinit var binding: ActivityMainBinding
private val locationsFragment = LocationsFragment()
private val settingsFragment = Settings()

init{
FilePicker.readPermLauncher_SDK_R = registerForActivityResult(PermissionContract()){
if(FilePicker.isReadPermissionGranted(this))
FilePicker.show()
else{
FilePicker.permissionDeniedError(this)
finish()
}
}

FilePicker.readPermLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()){ isGranted ->
if(isGranted){
FilePicker.show()
}
else{
FilePicker.permissionDeniedError(this)
finish()
}
}
}

override fun onCreate(savedInstanceState: Bundle?){
super.onCreate(savedInstanceState)
delegate.localNightMode = GlobePreferences.getInstance(this).getNightMode()
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
setSupportActionBar(binding.toolbar)
binding.toolbar.setNavigationOnClickListener{
onBackPressed()
}

locationsFragment.sendIntent(intent)

if(GlobePreferences.getInstance(this).getPath() == null)
FilePicker.show(this, supportFragmentManager)

if(savedInstanceState == null){
supportFragmentManager.beginTransaction().apply {
add(R.id.container, locationsFragment, LocationsFragment.TAG)
commit()
}
}

supportFragmentManager.onArkPathPicked(this) {
val globePrefs = GlobePreferences.getInstance(this)
globePrefs.storePath("$it${Settings.FOLDER_NAME}")
}
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.main_menu, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
when(item.itemId){
R.id.settings -> {
supportFragmentManager.beginTransaction().apply {
val backStackName = settingsFragment.javaClass.name
val popBackStack = supportFragmentManager.popBackStackImmediate(backStackName, 0)
if(!popBackStack) {
replace(R.id.container, settingsFragment, Settings.TAG)
addToBackStack(backStackName)
commit()
}
else{
show(settingsFragment)
commit()
}
}
}
}
return true
}
}
40 changes: 40 additions & 0 deletions app/src/main/kotlin/com/ark/globe/adapters/LocationsAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.ark.globe.adapters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.ark.globe.R
import com.ark.globe.coordinates.Location

class LocationsAdapter(private val locations: List<Location>):
RecyclerView.Adapter<LocationsAdapter.LocationsViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): LocationsViewHolder {
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.coordinate_view, parent, false)
return LocationsViewHolder(itemView)
}

override fun getItemCount(): Int {
return locations.size
}

override fun onBindViewHolder(
holder: LocationsViewHolder,
position: Int
) {
val coordinates = "${locations[position].coordinates.latitude}, ${locations[position].coordinates.longitude}"
holder.apply{
locationName.text = locations[position].name
locationDesc.text = locations[position].description
this.coordinates.text = coordinates
}
}

class LocationsViewHolder(itemView: View): RecyclerView.ViewHolder(itemView){
val locationName: TextView = itemView.findViewById(R.id.locationName)
val locationDesc: TextView = itemView.findViewById(R.id.locationDesc)
val coordinates: TextView = itemView.findViewById(R.id.coordinates)
}
}
Loading