Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[![](https://jitpack.io/v/hypersoftdev/PuzzleLayout.svg)](https://jitpack.io/#hypersoftdev/PuzzleLayout)
# PuzzleLayouts

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
android:theme="@style/Theme.PuzzleLayout"
tools:targetApi="31">
<activity
android:screenOrientation="fullSensor"
android:screenOrientation="portrait"
android:name=".app.flow.entrance.ui.MainActivity"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import com.hypersoft.pzlayout.interfaces.PuzzleLayout
import com.hypersoft.pzlayout.layouts.slant.SlantLayoutHelper
import com.hypersoft.pzlayout.layouts.slant.ThreeSlantLayout
import com.hypersoft.pzlayout.layouts.slant.TwoSlantLayout
import com.hypersoft.pzlayout.layouts.straight.EightStraightLayout
import com.hypersoft.pzlayout.layouts.straight.FiveStraightLayout
import com.hypersoft.pzlayout.layouts.straight.FourStraightLayout
import com.hypersoft.pzlayout.layouts.straight.NineStraightLayout
import com.hypersoft.pzlayout.layouts.straight.SevenStraightLayout
import com.hypersoft.pzlayout.layouts.straight.SixStraightLayout
import com.hypersoft.pzlayout.layouts.straight.StraightLayoutHelper
import com.hypersoft.pzlayout.layouts.straight.ThreeStraightLayout
import com.hypersoft.pzlayout.layouts.straight.TwoStraightLayout
Expand All @@ -26,6 +30,10 @@ class PuzzleUtils {
3 -> ThreeStraightLayout(themeId)
4 -> FourStraightLayout(themeId)
5 -> FiveStraightLayout(themeId)
6 -> SixStraightLayout(themeId)
7 -> SevenStraightLayout(themeId)
8 -> EightStraightLayout(themeId)
9 -> NineStraightLayout(themeId)
else -> TwoStraightLayout(themeId)
}
}
Expand All @@ -40,6 +48,10 @@ class PuzzleUtils {
addAll(StraightLayoutHelper.getAllThemeLayout(3))
addAll(StraightLayoutHelper.getAllThemeLayout(4))
addAll(StraightLayoutHelper.getAllThemeLayout(5))
addAll(StraightLayoutHelper.getAllThemeLayout(6))
addAll(StraightLayoutHelper.getAllThemeLayout(7))
addAll(StraightLayoutHelper.getAllThemeLayout(8))
addAll(StraightLayoutHelper.getAllThemeLayout(9))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ class FragmentLayoutWithImages : BaseFragment<FragmentLayoutWithImagesBinding>(F
val pieces: MutableList<Bitmap> = ArrayList()

val resIds = intArrayOf(
R.drawable.demo1, R.drawable.demo2, R.drawable.demo3, R.drawable.demo4, R.drawable.demo5
R.drawable.demo1, R.drawable.demo2, R.drawable.demo3,
R.drawable.demo4, R.drawable.demo5, R.drawable.demo6,
R.drawable.demo7, R.drawable.demo8, R.drawable.demo9,
)

// Determine the number of images to load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class FragmentMediaImageDetail : BaseFragment<FragmentMediaImageDetailBinding>(F
private fun setUpListener() = binding.apply {
nextButtonId.setOnClickListener {
if (selectedImage.isNotEmpty()) {
if (selectedImage.size <= 5) {
if (selectedImage.size <= 9) {
navigateTo(R.id.fragmentMediaImage, R.id.action_fragmentMediaImage_to_fragmentMediaImagesLayouts)
} else {
context?.showToast(R.string.select_only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ class FragmentMediaImagesLayouts : BaseFragment<FragmentMediaImagesLayoutsBindin
viewModelPuzzleLayouts.getPuzzleLayout(1, it.size, 0)
}

6 -> {
viewModelPuzzleLayouts.getPuzzleLayout(1, it.size, 0)
}

7 -> {
viewModelPuzzleLayouts.getPuzzleLayout(1, it.size, 0)
}

8 -> {
viewModelPuzzleLayouts.getPuzzleLayout(1, it.size, 0)
}

9 -> {
viewModelPuzzleLayouts.getPuzzleLayout(1, it.size, 0)
}

else -> {

}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<string name="layouts">Layouts</string>
<string name="home">Home</string>
<string name="select">Please Select Images</string>
<string name="select_only">You can select only five images</string>
<string name="select_only">You can select only Nine images</string>
<string name="pswap">Swap</string>
<string name="pmirror">Mirror</string>
<string name="pflip">Flip</string>
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Sep 19 10:59:37 PKT 2024
#Sun Nov 10 13:02:11 PKT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-rc-1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.hypersoft.pzlayout.layouts.straight

import com.hypersoft.pzlayout.interfaces.Line

class EightStraightLayout(theme: Int) : NumberStraightLayout(theme) {

override fun getThemeCount(): Int {
return 11
}

override fun layout() {
when (theme) {
0 -> cutAreaEqualPart(0, 3, 1)
1 -> cutAreaEqualPart(0, 1, 3)
2 -> {
cutAreaEqualPart(0, 4, Line.Direction.VERTICAL)
addLine(3, Line.Direction.HORIZONTAL, 4f / 5)
addLine(2, Line.Direction.HORIZONTAL, 3f / 5)
addLine(1, Line.Direction.HORIZONTAL, 2f / 5)
addLine(0, Line.Direction.HORIZONTAL, 1f / 5)
}

3 -> {
cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL)
addLine(3, Line.Direction.VERTICAL, 4f / 5)
addLine(2, Line.Direction.VERTICAL, 3f / 5)
addLine(1, Line.Direction.VERTICAL, 2f / 5)
addLine(0, Line.Direction.VERTICAL, 1f / 5)
}

4 -> {
cutAreaEqualPart(0, 4, Line.Direction.VERTICAL)
addLine(3, Line.Direction.HORIZONTAL, 1f / 5)
addLine(2, Line.Direction.HORIZONTAL, 2f / 5)
addLine(1, Line.Direction.HORIZONTAL, 3f / 5)
addLine(0, Line.Direction.HORIZONTAL, 4f / 5)
}

5 -> {
cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL)
addLine(3, Line.Direction.VERTICAL, 1f / 5)
addLine(2, Line.Direction.VERTICAL, 2f / 5)
addLine(1, Line.Direction.VERTICAL, 3f / 5)
addLine(0, Line.Direction.VERTICAL, 4f / 5)
}

6 -> {
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
cutAreaEqualPart(2, 3, Line.Direction.VERTICAL)
cutAreaEqualPart(1, 2, Line.Direction.VERTICAL)
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
}

7 -> {
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
cutAreaEqualPart(2, 3, Line.Direction.HORIZONTAL)
cutAreaEqualPart(1, 2, Line.Direction.HORIZONTAL)
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
}

8 -> {
addLine(0, Line.Direction.HORIZONTAL, 4f / 5)
cutAreaEqualPart(1, 5, Line.Direction.VERTICAL)
addLine(0, Line.Direction.HORIZONTAL, 1f / 2)
addLine(1, Line.Direction.VERTICAL, 1f / 2)
}

9 -> {
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
cutAreaEqualPart(2, 2, Line.Direction.VERTICAL)
cutAreaEqualPart(1, 3, Line.Direction.VERTICAL)
addLine(0, Line.Direction.VERTICAL, 3f / 4)
addLine(0, Line.Direction.VERTICAL, 1f / 3)
}

10 -> {
cutAreaEqualPart(0, 2, 1)
addLine(5, Line.Direction.VERTICAL, 1f / 2)
addLine(4, Line.Direction.VERTICAL, 1f / 2)
}

else -> {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.hypersoft.pzlayout.layouts.straight

import com.hypersoft.pzlayout.interfaces.Line

class NineStraightLayout(theme: Int) : NumberStraightLayout(theme) {

override fun getThemeCount(): Int {
return 8
}

override fun layout() {
when (theme) {
0 -> cutAreaEqualPart(0, 2, 2)
1 -> {
addLine(0, Line.Direction.VERTICAL, 3f / 4)
addLine(0, Line.Direction.VERTICAL, 1f / 3)
cutAreaEqualPart(2, 4, Line.Direction.HORIZONTAL)
cutAreaEqualPart(0, 4, Line.Direction.HORIZONTAL)
}

2 -> {
addLine(0, Line.Direction.HORIZONTAL, 3f / 4)
addLine(0, Line.Direction.HORIZONTAL, 1f / 3)
cutAreaEqualPart(2, 4, Line.Direction.VERTICAL)
cutAreaEqualPart(0, 4, Line.Direction.VERTICAL)
}

3 -> {
addLine(0, Line.Direction.HORIZONTAL, 3f / 4)
addLine(0, Line.Direction.HORIZONTAL, 1f / 3)
cutAreaEqualPart(2, 3, Line.Direction.VERTICAL)
addLine(1, Line.Direction.VERTICAL, 3f / 4)
addLine(1, Line.Direction.VERTICAL, 1f / 3)
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
}

4 -> {
addLine(0, Line.Direction.VERTICAL, 3f / 4)
addLine(0, Line.Direction.VERTICAL, 1f / 3)
cutAreaEqualPart(2, 3, Line.Direction.HORIZONTAL)
addLine(1, Line.Direction.HORIZONTAL, 3f / 4)
addLine(1, Line.Direction.HORIZONTAL, 1f / 3)
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
}

5 -> {
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
addLine(2, Line.Direction.HORIZONTAL, 3f / 4)
addLine(2, Line.Direction.HORIZONTAL, 1f / 3)
cutAreaEqualPart(1, 3, Line.Direction.HORIZONTAL)
addLine(0, Line.Direction.HORIZONTAL, 3f / 4)
addLine(0, Line.Direction.HORIZONTAL, 1f / 3)
}

6 -> {
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
addLine(2, Line.Direction.VERTICAL, 3f / 4)
addLine(2, Line.Direction.VERTICAL, 1f / 3)
cutAreaEqualPart(1, 3, Line.Direction.VERTICAL)
addLine(0, Line.Direction.VERTICAL, 3f / 4)
addLine(0, Line.Direction.VERTICAL, 1f / 3)
}

7 -> {
addLine(0, Line.Direction.HORIZONTAL, 1f / 2)
cutAreaEqualPart(1, 1, 3)
}

else -> {}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.hypersoft.pzlayout.layouts.straight

import com.hypersoft.pzlayout.interfaces.Line

class SevenStraightLayout(theme: Int) : NumberStraightLayout(theme) {

override fun getThemeCount(): Int {
return 9
}

override fun layout() {
when (theme) {
0 -> {
addLine(0, Line.Direction.HORIZONTAL, 1f / 2)
cutAreaEqualPart(1, 4, Line.Direction.VERTICAL)
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
}

1 -> {
addLine(0, Line.Direction.VERTICAL, 1f / 2)
cutAreaEqualPart(1, 4, Line.Direction.HORIZONTAL)
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
}

2 -> {
addLine(0, Line.Direction.HORIZONTAL, 1f / 2)
cutAreaEqualPart(1, 1, 2)
}

3 -> {
addLine(0, Line.Direction.HORIZONTAL, 2f / 3)
cutAreaEqualPart(1, 3, Line.Direction.VERTICAL)
addCross(0, 1f / 2)
}

4 -> {
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
cutAreaEqualPart(2, 3, Line.Direction.HORIZONTAL)
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
}

5 -> {
addLine(0, Line.Direction.HORIZONTAL, 2f / 3)
addLine(1, Line.Direction.VERTICAL, 3f / 4)
addLine(0, Line.Direction.HORIZONTAL, 1f / 2)
addLine(1, Line.Direction.VERTICAL, 2f / 5)
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
}

6 -> {
addLine(0, Line.Direction.VERTICAL, 2f / 3)
addLine(1, Line.Direction.HORIZONTAL, 3f / 4)
addLine(0, Line.Direction.VERTICAL, 1f / 2)
addLine(1, Line.Direction.HORIZONTAL, 2f / 5)
cutAreaEqualPart(0, 3, Line.Direction.HORIZONTAL)
}

7 -> {
addLine(0, Line.Direction.VERTICAL, 1f / 4)
addLine(1, Line.Direction.VERTICAL, 2f / 3)
addLine(2, Line.Direction.HORIZONTAL, 1f / 2)
addLine(1, Line.Direction.HORIZONTAL, 3f / 4)
addLine(1, Line.Direction.HORIZONTAL, 1f / 3)
addLine(0, Line.Direction.HORIZONTAL, 1f / 2)
}

8 -> {
addLine(0, Line.Direction.HORIZONTAL, 1f / 4)
addLine(1, Line.Direction.HORIZONTAL, 2f / 3)
cutAreaEqualPart(2, 3, Line.Direction.VERTICAL)
cutAreaEqualPart(0, 3, Line.Direction.VERTICAL)
}

else -> {}
}
}
}
Loading