Skip to content

Commit

Permalink
actions: *.lite check (fixes #3580) (#3639)
Browse files Browse the repository at this point in the history
Co-authored-by: Gideon Okuro <[email protected]>
Co-authored-by: dogi <[email protected]>
  • Loading branch information
3 people authored Jun 20, 2024
1 parent 793f543 commit c634de6
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 47 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 23 additions & 12 deletions app/src/main/AndroidManifest.xml.lite
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<!--<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>-->
<!-- <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>-->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:required="false" />
Expand Down Expand Up @@ -52,12 +52,14 @@
</activity>
<activity
android:name=".ui.sync.LoginActivity"
android:exported="false" />
android:exported="false"
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard"/>

<activity
android:name=".ui.userprofile.BecomeMemberActivity"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.course.CourseProgressActivity"
android:name=".ui.courses.CourseProgressActivity"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.news.NewsDetailActivity"
Expand All @@ -74,24 +76,33 @@
android:name=".ui.news.ReplyActivity"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.library.AddResourceActivity"
android:name=".ui.resources.AddResourceActivity"
android:theme="@style/AppTheme" />
<activity android:name=".ui.viewer.AudioPlayerActivity" />
<activity android:name=".ui.viewer.AudioPlayerActivity"
android:configChanges="orientation|screenSize" />
<activity
android:name=".ui.feedback.FeedbackDetailActivity"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.dashboard.DashboardActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/title_activity_dashboard"
android:windowSoftInputMode="adjustPan"
android:theme="@style/FullscreenTheme" />
<activity android:name=".ui.viewer.PDFReaderActivity" />
<activity android:name=".ui.viewer.WebViewActivity" />
<activity android:name=".ui.viewer.VideoPlayerActivity" />
<activity android:name=".ui.viewer.ImageViewerActivity" />
<activity android:name=".ui.viewer.TextFileViewerActivity" />
<activity android:name=".ui.viewer.MarkdownViewerActivity" />
<activity android:name=".ui.viewer.CSVViewerActivity" />
<activity android:name=".ui.viewer.PDFReaderActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.viewer.WebViewActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.viewer.VideoPlayerActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.viewer.ImageViewerActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.viewer.TextFileViewerActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.viewer.MarkdownViewerActivity"
android:configChanges="orientation|screenSize" />
<activity android:name=".ui.viewer.CSVViewerActivity"
android:configChanges="orientation|screenSize" />
<activity
android:name=".ui.dictionary.DictionaryActivity"
android:theme="@style/AppTheme" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
// }
// }
prefData = SharedPrefManager(requireContext())
}
}

fun setRatings(`object`: JsonObject?) {
if (`object` != null) {
Expand Down Expand Up @@ -302,6 +302,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
}

// open fun handleBackPressed() {
// requireActivity().onBackPressed()
// val fragmentManager = parentFragmentManager
// fragmentManager.popBackStack()
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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
}
Expand Down Expand Up @@ -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 -> {
Expand Down

0 comments on commit c634de6

Please sign in to comment.