diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 1ed9befd0d..256e6f15ae 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -22,6 +22,31 @@ jobs: - name: checkout repository code uses: actions/checkout@v4 + - name: ensure *.lite also change + if: matrix.build == 'lite' + run: | + git fetch origin master > /dev/null 2>&1 + files=( + "app/src/main/AndroidManifest.xml" + "app/src/main/AndroidManifest.xml.lite" + "app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt" + "app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite" + "app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt" + "app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite" + "app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt" + "app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite" + ) + errors=() + for ((i=0; i<${#files[@]}; i+=2)); do + file1=${files[i]} + file2=${files[i+1]} + changes=$(git diff --name-only HEAD origin/master | grep -E "^($file1|$file2)$") + if [ -n "$changes" ] && (! echo "$changes" | grep -qE "^($file1)$" || ! echo "$changes" | grep -qE "^($file2)$"); then + errors+=("Error: Both $file1 and $file2 must be changed together.") + fi + done + [ ${#errors[@]} -gt 0 ] && { printf "%s\n" "${errors[@]}"; exit 1; } + - name: diff the code to get lite if: matrix.build == 'lite' run: | diff --git a/app/build.gradle b/app/build.gradle index da651a46a0..c4430676f9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1609 - versionName "0.16.9" + versionCode 1610 + versionName "0.16.10" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/AndroidManifest.xml.lite b/app/src/main/AndroidManifest.xml.lite index 21c42e637b..84e04ea91f 100644 --- a/app/src/main/AndroidManifest.xml.lite +++ b/app/src/main/AndroidManifest.xml.lite @@ -2,7 +2,7 @@ - + @@ -52,12 +52,14 @@ + android:exported="false" + android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard"/> + - + @@ -84,14 +87,22 @@ android:name=".ui.dashboard.DashboardActivity" android:configChanges="orientation|screenSize|keyboardHidden" android:label="@string/title_activity_dashboard" + android:windowSoftInputMode="adjustPan" android:theme="@style/FullscreenTheme" /> - - - - - - - + + + + + + + diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt index afd38df55c..438a36a588 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt @@ -194,7 +194,6 @@ abstract class BaseContainerFragment : BaseResourceFragment() { setDataAndType(uri, "application/vnd.android.package-archive") flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK } - if (intent.resolveActivity(requireActivity().packageManager) != null) { if (hasInstallPermission(MainApplication.context)) { startActivity(intent) diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite index 47cd960fb2..6d3fe8f9d7 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite @@ -65,7 +65,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() { // } // } prefData = SharedPrefManager(requireContext()) - } + } fun setRatings(`object`: JsonObject?) { if (`object` != null) { @@ -302,6 +302,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } // open fun handleBackPressed() { -// requireActivity().onBackPressed() +// val fragmentManager = parentFragmentManager +// fragmentManager.popBackStack() // } } diff --git a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite index 7d9f6e26c1..eac354495d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite @@ -103,7 +103,7 @@ abstract class PermissionActivity : AppCompatActivity() { } companion object { - private const val PERMISSION_REQUEST_CODE_FILE = 111 + const val PERMISSION_REQUEST_CODE_FILE = 111 // @JvmStatic // fun hasInstallPermission(context: Context): Boolean { // return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt index 45ca3f434f..a5dc86f0fc 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt @@ -35,7 +35,7 @@ import com.mikepenz.materialdrawer.holder.DimenHolder import com.mikepenz.materialdrawer.model.PrimaryDrawerItem import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem import com.mikepenz.materialdrawer.model.interfaces.Nameable -import org.ole.planet.myplanet.MainApplication +import org.ole.planet.myplanet.MainApplication.Companion.context import org.ole.planet.myplanet.R import org.ole.planet.myplanet.base.BaseContainerFragment import org.ole.planet.myplanet.callback.OnHomeItemClickListener @@ -192,7 +192,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N } else { if (!doubleBackToExitPressedOnce) { doubleBackToExitPressedOnce = true - Utilities.toast(MainApplication.context, getString(R.string.press_back_again_to_exit)) + toast(context, getString(R.string.press_back_again_to_exit)) Handler(Looper.getMainLooper()).postDelayed({ doubleBackToExitPressedOnce = false }, 2000) } else { finish() @@ -217,7 +217,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N private fun checkUser() { user = UserProfileDbHandler(this).userModel if (user == null) { - Utilities.toast(this, getString(R.string.session_expired)) + toast(this, getString(R.string.session_expired)) logout() return } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite index 7963d81f10..56c23a909e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite @@ -15,6 +15,7 @@ import android.view.Menu import android.view.MenuItem import android.view.View import android.view.WindowManager +import androidx.activity.OnBackPressedCallback import androidx.core.content.ContextCompat import androidx.core.content.res.ResourcesCompat import androidx.drawerlayout.widget.DrawerLayout @@ -30,6 +31,7 @@ import com.mikepenz.materialdrawer.holder.DimenHolder import com.mikepenz.materialdrawer.model.PrimaryDrawerItem import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem import com.mikepenz.materialdrawer.model.interfaces.Nameable +import org.ole.planet.myplanet.MainApplication.Companion.context import org.ole.planet.myplanet.R //import org.ole.planet.myplanet.base.BaseContainerFragment import org.ole.planet.myplanet.callback.OnHomeItemClickListener @@ -174,6 +176,31 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, B menue = tl?.getTabAt(4) menuco = tl?.getTabAt(5) hideWifi() + + onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + if (result != null && result?.isDrawerOpen == true) { + result?.closeDrawer() + } else { + if (supportFragmentManager.backStackEntryCount > 1) { + supportFragmentManager.popBackStack() + } else { + if (!doubleBackToExitPressedOnce) { + doubleBackToExitPressedOnce = true + toast(context, getString(R.string.press_back_again_to_exit)) + Handler(Looper.getMainLooper()).postDelayed({ doubleBackToExitPressedOnce = false }, 2000) + } else { + finish() + } + } + } + +// val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container) +// if (fragment is BaseContainerFragment) { +// fragment.handleBackPressed() +// } + } + }) } private fun hideWifi() { @@ -185,7 +212,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, B private fun checkUser() { user = UserProfileDbHandler(this).userModel if (user == null) { - Utilities.toast(this, getString(R.string.session_expired)) + toast(this, getString(R.string.session_expired)) logout() return } @@ -375,31 +402,6 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, B .withIconTintingEnabled(true) } - override fun onBackPressed() { - if (result != null && result?.isDrawerOpen == true) { - result?.closeDrawer() - } else { - if (supportFragmentManager.backStackEntryCount > 1) { - supportFragmentManager.popBackStack() - } else { - if (!doubleBackToExitPressedOnce) { - this.doubleBackToExitPressedOnce = true - Utilities.toast(this, getString(R.string.press_back_again_to_exit)) - Handler(Looper.getMainLooper()).postDelayed({ doubleBackToExitPressedOnce = false }, 2000) - } else { - finish() - } - } - } - -// val fragment = supportFragmentManager.findFragmentById(R.id.fragment_container) -// if (fragment is BaseContainerFragment) { -// fragment.handleBackPressed() -// } else { -// super.onBackPressed() -// } - } - override fun onNavigationItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_library -> {