Skip to content

Commit

Permalink
Merge branch 'master' into 3699-warnings-in-myteamsdetailfragment
Browse files Browse the repository at this point in the history
  • Loading branch information
rlam20 authored Jul 2, 2024
2 parents 79ffeb7 + 2d1d244 commit c36d42d
Show file tree
Hide file tree
Showing 35 changed files with 340 additions and 234 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
matrix:
build: [default, lite]
env:
ANDROID_NDK_VERSION: "21.3.6528147"
ANDROID_SDK_ROOT: "/usr/local/lib/android/sdk"
FILES: |
app/src/main/AndroidManifest.xml
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
Expand Down Expand Up @@ -53,27 +51,6 @@ jobs:
distribution: 'zulu'
java-version: '17'

- name: cache NDK
id: cache-ndk
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.ANDROID_NDK_VERSION }}
key: ${{ runner.os }}-ndk-${{ env.ANDROID_NDK_VERSION }}
restore-keys: |
${{ runner.os }}-ndk-
- name: install NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
set -x
echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT} 2>&1
if [ $? -ne 0 ]; then
echo "SDK Manager command failed"
exit 1
fi
set +x
ls -al ${ANDROID_SDK_ROOT}/ndk
- name: setup gradle
uses: gradle/actions/setup-gradle@v3
with:
Expand Down
77 changes: 41 additions & 36 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,47 @@ jobs:
matrix:
build: [default, lite]
env:
ANDROID_NDK_VERSION: "21.3.6528147"
ANDROID_SDK_ROOT: "/usr/local/lib/android/sdk"
FILES: |
app/src/main/AndroidManifest.xml
app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt
app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt
app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt
steps:
- name: set more env
run: echo "BRANCHNAME="${GITHUB_REF##*/} >> $GITHUB_ENV

- name: checkout repository code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: expose version from build.gradle
if: matrix.build == 'lite'
uses: dogi/[email protected]
with:
expose-version-name: 'true'
expose-version-code: 'true'

- name: diff the code to get lite
if: matrix.build == 'lite'
run: |
echo "ANDROID_VERSION_NAME_ORIG=${ANDROID_VERSION_NAME}" >> $GITHUB_ENV
ls -al app/build.gradle
sed -i 's/\(versionName "[0-9.]\+\)"/\1-lite"/' app/build.gradle
echo "${{ env.FILES }}" | xargs -n 1 | while read file; do
ls -al $file*
cp "${file}.lite" "$file"
done
- name: expose version from build.gradle
uses: dogi/[email protected]
with:
expose-version-name: 'true'
expose-version-code: 'true'

- name: setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'

- name: cache NDK
id: cache-ndk
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_SDK_ROOT }}/ndk/${{ env.ANDROID_NDK_VERSION }}
key: ${{ runner.os }}-ndk-${{ env.ANDROID_NDK_VERSION }}
restore-keys: |
${{ runner.os }}-ndk-
- name: install NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
set -x
echo "y" | sudo ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${ANDROID_NDK_VERSION}" --sdk_root=${ANDROID_SDK_ROOT} 2>&1
if [ $? -ne 0 ]; then
echo "SDK Manager command failed"
exit 1
fi
set +x
ls -al ${ANDROID_SDK_ROOT}/ndk
- name: setup gradle
uses: gradle/actions/setup-gradle@v3
with:
Expand All @@ -92,7 +73,7 @@ jobs:
cp app/build/outputs/apk/release/app-release-unsigned.apk sign/.
- name: sign release APK and AAB
uses: dogi/sign-android-release@v5
uses: dogi/sign-android-release@v5.1
with:
releaseDirectory: sign
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
Expand All @@ -110,8 +91,10 @@ jobs:
ls -alR output
- name: publish AAB to playstore
if: (github.ref == 'refs/heads/master') && (matrix.build == 'lite')
uses: dogi/[email protected]
id: playstore
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite'
continue-on-error: true
uses: dogi/[email protected]
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: org.ole.planet.myplanet
Expand All @@ -120,26 +103,48 @@ jobs:
releaseName: "${{ env.ANDROID_VERSION_CODE }} (${{ env.ANDROID_VERSION_NAME }})"
status: completed

- name: publish AAB to playstore fallback
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite' && steps.playstore.outcome == 'failure'
uses: dogi/[email protected]
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: org.ole.planet.myplanet
releaseFiles: output/myPlanet.aab
track: internal
releaseName: "${{ env.ANDROID_VERSION_CODE }} (${{ env.ANDROID_VERSION_NAME }})"
status: completed
changesNotSentForReview: true

- name: rename APK and AAB with version and branch for artifact
if: github.ref != 'refs/heads/master'
if: github.event_name == 'workflow_dispatch'
run: |
mv output/myPlanet.apk output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk
mv output/myPlanet.apk.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.apk.sha256
mv output/myPlanet.aab output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab
mv output/myPlanet.aab.sha256 output/myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}.aab.sha256
ls -alR output
echo "BRANCHNAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
- name: upload APK and AAB as build artifact
if: github.ref != 'refs/heads/master'
if: github.event_name == 'workflow_dispatch'
uses: actions/upload-artifact@v4
with:
name: myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}-${{ matrix.build }}
name: myPlanet-${{ env.ANDROID_VERSION_NAME }}-${{ env.BRANCHNAME }}
path: output/*
retention-days: 9

- name: pre-process files and tag for lite version
if: github.event_name != 'workflow_dispatch' && matrix.build == 'lite'
run: |
mv output/myPlanet.apk output/myPlanet-lite.apk
mv output/myPlanet.apk.sha256 output/myPlanet-lite.apk.sha256
mv output/myPlanet.aab output/myPlanet-lite.aab
mv output/myPlanet.aab.sha256 output/myPlanet-lite.aab.sha256
echo "ANDROID_VERSION_NAME=${ANDROID_VERSION_NAME_ORIG}" >> $GITHUB_ENV
- name: release APK and AAB on GitHub
if: github.ref == 'refs/heads/master'
uses: dogi/upload-release-action@v2.7.1
if: github.event_name != 'workflow_dispatch'
uses: dogi/upload-release-action@v2.9.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: output/*
Expand All @@ -148,7 +153,7 @@ jobs:
file_glob: 'true'

- name: send success message to discord
if: (github.ref == 'refs/heads/master') && (matrix.build != 'lite')
if: github.event_name != 'workflow_dispatch' && matrix.build != 'lite'
run: |
sudo npm install -g @treehouses/cli
export discord_channel="${{ secrets.CHANNEL }}" #remote
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 1623
versionName "0.16.23"
versionCode 1640
versionName "0.16.40"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/ole/planet/myplanet/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks {
Utilities.setContext(base)
}

override fun onConfigurationChanged(newConfig: android.content.res.Configuration) {
super.onConfigurationChanged(newConfig)
LocaleHelper.onAttach(this)
}

override fun onActivityCreated(activity: Activity, bundle: Bundle?) {}

override fun onActivityStarted(activity: Activity) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ package org.ole.planet.myplanet.base
import android.R
import android.os.Bundle
import android.view.MenuItem
import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import org.ole.planet.myplanet.utilities.LocaleHelper

abstract class BaseActivity : AppCompatActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}

override fun attachBaseContext(newBase: Context) {
super.attachBaseContext(LocaleHelper.onAttach(newBase))
}

fun initActionBar() {
supportActionBar?.setHomeButtonEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.ole.planet.myplanet.base

import android.R
import org.ole.planet.myplanet.R
import android.os.Bundle
import androidx.fragment.app.DialogFragment

Expand All @@ -9,7 +9,7 @@ abstract class BaseDialogFragment : DialogFragment() {
var id: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.Theme_Holo_Light_Dialog_NoActionBar_MinWidth)
setStyle(STYLE_NO_TITLE, R.style.AppTheme_Dialog_NoActionBar_MinWidth)
if (arguments != null) {
id = requireArguments().getString(key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
"members" -> (v as TextView).setText(R.string.no_join_request_available)
"discussions" -> (v as TextView).setText(R.string.no_news)
"survey" -> (v as TextView).setText(R.string.no_surveys)
"submission" -> (v as TextView).setText(R.string.no_submissions)
"chatHistory" -> (v as TextView).setText(R.string.no_chats)
else -> (v as TextView).setText(R.string.no_data_available_please_check_and_try_again)
}
}
Expand Down
18 changes: 11 additions & 7 deletions app/src/main/java/org/ole/planet/myplanet/datamanager/ApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ object ApiClient {
val client = OkHttpClient.Builder().connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build()
if (retrofit == null) {
retrofit = Retrofit.Builder().baseUrl(BASE_URL).client(client).addConverterFactory(
GsonConverterFactory.create(
GsonBuilder().setLenient()
.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
.serializeNulls().create()
)
).build()
retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(
GsonConverterFactory.create(
GsonBuilder()
.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
.serializeNulls()
.create()
)
).build()
}
return retrofit
}
Expand Down
Loading

0 comments on commit c36d42d

Please sign in to comment.