Skip to content

Commit

Permalink
#17 in progress - build variants
Browse files Browse the repository at this point in the history
  • Loading branch information
mjureczko committed Jul 16, 2024
1 parent dfbbff1 commit ac16c30
Show file tree
Hide file tree
Showing 229 changed files with 4,141 additions and 4,234 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ GPLv3 (https://www.gnu.org/licenses/gpl-3.0.html)
TODO:
- remove dead code
- prepare custom version artifact for the play shop
- add doDommemorativePhoto to searching screen
- - "Photo has been repalced" toast after creating a new commemorative photo
36 changes: 33 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
android {
compileSdkVersion 33
defaultConfig {
applicationId "pl.marianjureczko.poszukiwacz.kalinowice"
applicationId "pl.marianjureczko.poszukiwacz"
minSdkVersion 23
targetSdkVersion 33
versionCode 1
Expand All @@ -32,7 +32,7 @@ android {
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
resValue "string", "main_ad", "ca-app-pub-6283649742373707/7715917886"
resValue "string", "searching_ad", "ca-app-pub-6283649742373707/9491764484"
Expand All @@ -44,6 +44,36 @@ android {
resValue "string", "photo_ad", "ca-app-pub-3940256099942544/6300978111"
}
}
flavorDimensions "assets", "mode"
productFlavors {
classic {
dimension "mode"
}

custom {
dimension "mode"

}

defaultAssets {
dimension "assets"
}

kalinowice {
dimension "assets"
applicationIdSuffix ".kalinowice"
}
}
variantFilter { variant ->
def names = variant.flavors*.name
if (names.contains("custom") && names.contains("defaultAssets")) {
setIgnore(true)
}
if (names.contains("classic") && !name.contains("defaultAssets")) {
setIgnore(true)
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
Expand All @@ -56,7 +86,7 @@ android {
buildFeatures {
compose true
}

composeOptions {
kotlinCompilerExtensionVersion compose_version
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import pl.marianjureczko.poszukiwacz.model.TreasuresProgress

abstract class ReportAbstractTest {
val context: Context = InstrumentationRegistry.getInstrumentation().targetContext
val model: FacebookViewModel = FacebookViewModel(SavedStateHandle(mapOf()))
val model: pl.marianjureczko.poszukiwacz.activity.facebook.FacebookViewModel =
pl.marianjureczko.poszukiwacz.activity.facebook.FacebookViewModel(SavedStateHandle(mapOf()))
val font: Typeface = ResourcesCompat.getFont(context, R.font.akaya_telivigala)!!
val treasuresProgress: TreasuresProgress = TreasuresProgress("123456789", TreasureDescription.nullObject())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ internal class ReportCommemorativePhotosTest : ReportAbstractTest() {
@Test
fun shouldDrawCommemorativePhotosInSingleLine_when2() {
//given
val bitmap = Bitmap.createBitmap(ReportCommons.REPORT_WIDTH, 800, Bitmap.Config.ARGB_8888)
val bitmap = Bitmap.createBitmap(pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommons.REPORT_WIDTH, 800, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(1, tempPhoto(800, 400))
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(2, tempPhoto(600, 600))

StorageHelper(context).save(Route(treasuresProgress.routeName))
model.initialize(context, null, treasuresProgress)
val reportPhotos = ReportCommemorativePhotos(model, font, seed)
val reportPhotos = pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommemorativePhotos(model, font, seed)

//when
reportPhotos.draw(context, canvas, 0f)
Expand All @@ -52,15 +52,15 @@ internal class ReportCommemorativePhotosTest : ReportAbstractTest() {
@Test
fun shouldDrawCommemorativePhotosIn2Lines_when4() {
//given
val bitmap = Bitmap.createBitmap(ReportCommons.REPORT_WIDTH, 800, Bitmap.Config.ARGB_8888)
val bitmap = Bitmap.createBitmap(pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommons.REPORT_WIDTH, 800, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(1, tempPhoto(800, 400))
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(2, tempPhoto(600, 600))
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(3, tempPhoto(400, 800))
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(4, tempPhoto(600, 500))
model.initialize(context, null, treasuresProgress)
val reportPhotos = ReportCommemorativePhotos(model, font, seed)
val reportPhotos = pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommemorativePhotos(model, font, seed)

//when
reportPhotos.draw(context, canvas, 0f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class ReportFooterTest : ReportAbstractTest() {
@Test
fun should_drawFooter() {
//given
val footer = ReportFooter()
val bitmap = Bitmap.createBitmap(ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val footer = pl.marianjureczko.poszukiwacz.activity.facebook.ReportFooter()
val bitmap = Bitmap.createBitmap(pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ReportGeneratorTest {
@Test
fun shouldCreateImage() {
//given
val report = ReportGenerator()
val report = pl.marianjureczko.poszukiwacz.activity.facebook.ReportGenerator()
val context = InstrumentationRegistry.getInstrumentation().targetContext
val photos = arrangePhotos(context)
val treasuresProgress = TreasuresProgress("123456789 123456789 123456789 123456789 12345", TreasureDescription.nullObject())
Expand All @@ -36,16 +36,16 @@ class ReportGeneratorTest {
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(13, photos[4])
treasuresProgress.commemorativePhotosByTreasuresDescriptionIds.put(0, photos[5])
val hunterPath = HunterPath()
hunterPath.addLocation(Coordinates(10.0, 10.0), Date(1))
hunterPath.addLocation(Coordinates(10.0, 11.0), Date(1_000_000))
hunterPath.addLocation(Coordinates(10.0, 11.0), Date(2_000_000))
hunterPath.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(10.0, 10.0), Date(1))
hunterPath.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(10.0, 11.0), Date(1_000_000))
hunterPath.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(10.0, 11.0), Date(2_000_000))
StorageHelper(context).save(Route(treasuresProgress.routeName))

//when
val model = FacebookViewModel(SavedStateHandle(mapOf()))
val model = pl.marianjureczko.poszukiwacz.activity.facebook.FacebookViewModel(SavedStateHandle(mapOf()))
model.initialize(context, hunterPath, treasuresProgress)
//MapBox doesn't work in tests
val mapIdx = model.elements.indices.find { model.elements[it].type == Type.MAP }!!
val mapIdx = model.elements.indices.find { model.elements[it].type == pl.marianjureczko.poszukiwacz.activity.facebook.Type.MAP }!!
val elements = model.elements.toMutableList()
elements[mapIdx] = model.elements[mapIdx].copy(isSelected = false)
model.elements = elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ReportMapHeaderTest : ReportAbstractTest() {
@Test
fun shouldDrawSummary() {
//given
val reportMapHeader = ReportMapHeader(model, font)
val bitmap = Bitmap.createBitmap(ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val reportMapHeader = pl.marianjureczko.poszukiwacz.activity.facebook.ReportMapHeader(model, font)
val bitmap = Bitmap.createBitmap(pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)
model.initialize(context, null, treasuresProgress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class ReportMapSummaryTest : ReportAbstractTest() {
@Test
fun should_drawSummaryWithLengthAndTimestamps() {
//given
val reportMapHeader = ReportMapSummary(model, font)
val bitmap = Bitmap.createBitmap(ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val reportMapHeader = pl.marianjureczko.poszukiwacz.activity.facebook.ReportMapSummary(model, font)
val bitmap = Bitmap.createBitmap(pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)
val hunterPath = HunterPath()
hunterPath.addLocation(Coordinates(10.0, 10.0), Date(1))
hunterPath.addLocation(Coordinates(10.0, 11.0), Date(1_000_000))
hunterPath.addLocation(Coordinates(10.0, 11.0), Date(2_000_000))
hunterPath.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(10.0, 10.0), Date(1))
hunterPath.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(10.0, 11.0), Date(1_000_000))
hunterPath.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(10.0, 11.0), Date(2_000_000))
model.initialize(context, hunterPath, treasuresProgress)

//when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ internal class ReportSummaryTest : ReportAbstractTest() {
@Test
fun shouldDrawSummary() {
//given
val reportSummary = ReportSummary(model, font)
val bitmap = Bitmap.createBitmap(ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val reportSummary = pl.marianjureczko.poszukiwacz.activity.facebook.ReportSummary(model, font)
val bitmap = Bitmap.createBitmap(pl.marianjureczko.poszukiwacz.activity.facebook.ReportCommons.REPORT_WIDTH, 200, Bitmap.Config.ARGB_8888)
val canvas = Canvas(bitmap)
canvas.drawColor(Color.WHITE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class HunterPathTest {
fun shouldCalculateDistance() {
//given
val path = HunterPath()
path.addLocation(Coordinates(51.1428, 16.5254), Date(0))
path.addLocation(Coordinates(51.1534, 16.54076), Date(100_000))
path.addLocation(Coordinates(51.14499, 16.55419), Date(200_000))
path.addLocation(Coordinates(51.14499, 16.55419), Date(300_000))
path.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(51.1428, 16.5254), Date(0))
path.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(51.1534, 16.54076), Date(100_000))
path.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(51.14499, 16.55419), Date(200_000))
path.addLocation(pl.marianjureczko.poszukiwacz.activity.treasureselector.Coordinates(51.14499, 16.55419), Date(300_000))

//when
val actual = path.pathLengthInKm()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//package pl.marianjureczko.poszukiwacz.activity.bluetooth
//
//import android.bluetooth.BluetoothDevice
//import android.view.View
//import android.widget.Button
//import androidx.recyclerview.widget.RecyclerView
//import pl.marianjureczko.poszukiwacz.R
//
//abstract class AbstractDeviceHolder(view: View) : RecyclerView.ViewHolder(view) {
//
// val deviceName: Button = itemView.findViewById((R.id.device_name))
//
// abstract fun setupView(device: BluetoothDevice)
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//package pl.marianjureczko.poszukiwacz.activity.bluetooth
//
//import android.annotation.SuppressLint
//import android.bluetooth.BluetoothServerSocket
//import android.bluetooth.BluetoothSocket
//import android.content.Context
//import android.util.Log
//import pl.marianjureczko.poszukiwacz.R
//import pl.marianjureczko.poszukiwacz.activity.main.Bluetooth
//import java.io.IOException
//
//@SuppressLint("MissingPermission")
//class AcceptThread(
// memoConsole: MemoConsole,
// private val bluetooth: Bluetooth,
// private val bluetoothConnectionManager: BluetoothConnectionManager,
// private val context: Context
//) : CancellableThread(memoConsole) {
//
// private val TAG = javaClass.simpleName
// private val serverSocket: BluetoothServerSocket? by lazy(LazyThreadSafetyMode.PUBLICATION) {
// bluetooth.adapter?.listenUsingRfcommWithServiceRecord(Bluetooth.NAME, MY_BLUETOOTH_UUID)
// }
//
// override fun run() {
// if (serverSocket == null) {
// printInConsole(context.getString(R.string.no_bluetooth_to_receive_route))
// return
// }
// // Keep listening until exception occurs or a socket is returned.
// var shouldLoop = true
// while (shouldLoop) {
// val socket: BluetoothSocket? = try {
// printInConsole(context.getString(R.string.bluetooth_waiting_to_accept))
// serverSocket?.accept()
// } catch (e: IOException) {
// printInConsole(context.getString(R.string.accepting_bluetooth_connection_error) + e.message)
// shouldLoop = false
// null
// }
// socket?.also {
// printInConsole(context.getString(R.string.bluetooth_connection_accepted))
// bluetoothConnectionManager.readRuteFromConnectedSocket(it)
// serverSocket?.close()
// shouldLoop = false
// }
// }
// }
//
// override fun cancel() {
// super.cancel()
// try {
// serverSocket?.close()
// } catch (e: IOException) {
// Log.e(TAG, "Could not close the connect socket", e)
// }
// }
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//package pl.marianjureczko.poszukiwacz.activity.main
//
//import android.annotation.SuppressLint
//import android.bluetooth.BluetoothAdapter
//import android.bluetooth.BluetoothClass
//import android.bluetooth.BluetoothDevice
//import pl.marianjureczko.poszukiwacz.R
//
//class BluetoothException(val msgId: Int) : Exception()
//
//class Bluetooth(
//// private val permissionsManager: PermissionsManager
//) {
// companion object {
// val NAME = "MALY_POSZUKIWACZ_SKARBOW"
// }
//
// val adapter: BluetoothAdapter? by lazy {
// BluetoothAdapter.getDefaultAdapter()
// }
//
// @SuppressLint("MissingPermission")
// @Throws(BluetoothException::class)
// fun findDevices(): List<BluetoothDevice> {
// if (adapter == null) {
// throw BluetoothException(R.string.no_bluetooth)
// }
// if (!adapter!!.isEnabled) {
// throw BluetoothException(R.string.bluetooth_disabled)
// }
// return adapter?.bondedDevices
// ?.filter {
// it.bluetoothClass.majorDeviceClass == BluetoothClass.Device.Major.PHONE
// }
// ?: listOf()
// }
//
// fun isConnected() {
// // https://stackoverflow.com/questions/4715865/how-can-i-programmatically-tell-if-a-bluetooth-device-is-connected
// // public void onCreate() {
// // ...
// // IntentFilter filter = new IntentFilter();
// // filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
// // filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
// // filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
// // this.registerReceiver(mReceiver, filter);
// //}
// //
// ////The BroadcastReceiver that listens for bluetooth broadcasts
// //private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
// // @Override
// // public void onReceive(Context context, Intent intent) {
// // String action = intent.getAction();
// // BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// //
// // if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// // ... //Device found
// // }
// // else if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action)) {
// // ... //Device is now connected
// // }
// // else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
// // ... //Done searching
// // }
// // else if (BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED.equals(action)) {
// // ... //Device is about to disconnect
// // }
// // else if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
// // ... //Device has disconnected
// // }
// // }
// //};
// }
//}
Loading

0 comments on commit ac16c30

Please sign in to comment.