-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a workflow to generate release APK using input keys and zon…
…es (#31)
- Loading branch information
1 parent
43552be
commit b2aea8a
Showing
23 changed files
with
362 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Android Dynamic Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tapsellAppKey: | ||
description: 'Tapsell App Key' | ||
required: true | ||
default: '76798342-99a7-4a5f-bf5a-60a088d5dcfb' | ||
AdmobAppKey: | ||
description: 'Admob App Key' | ||
required: true | ||
default: 'ca-app-pub-3940256099942544~3347511713' | ||
ApplovinAppKey: | ||
description: 'Applovin App Key' | ||
required: true | ||
default: '5WfZLCGTQmDr6Mf7BBEf5blVwrf8VBMJSmwUSq9-1q5bPpCH_OGAWEP2z2lRkmonLgPzG6gbL4DlvUF9frFmt6' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: gradle | ||
|
||
- name: Decode Keystore | ||
env: | ||
# Create `SIGNING_KEY_STORE_BASE64` environment in GitHub secrets and place the base64 encoded value | ||
# of your keystore there. | ||
ENCODED_STRING: ${{ secrets.SIGNING_KEY_STORE_BASE64 }} | ||
SIGNING_KEY_STORE_PATH: ${{ secrets.MYAPP_RELEASE_STORE_FILE }} | ||
|
||
run: | | ||
echo "keystore path: $MYAPP_RELEASE_STORE_FILE" | ||
echo $ENCODED_STRING > keystore-b64.txt | ||
base64 -d keystore-b64.txt > release.keystore | ||
- name: Build Release apk | ||
env: | ||
SIGNING_KEY_STORE_PATH: ${{ secrets.MYAPP_RELEASE_STORE_FILE }} | ||
SIGNING_KEY_ALIAS: ${{ secrets.MYAPP_RELEASE_KEY_ALIAS }} | ||
SIGNING_KEY_PASSWORD: ${{ secrets.MYAPP_RELEASE_KEY_PASSWORD }} | ||
SIGNING_STORE_PASSWORD: ${{ secrets.MYAPP_RELEASE_STORE_PASSWORD }} | ||
run: | | ||
sh ./scripts/change-app.sh "${{ github.event.inputs.tapsellAppKey }}" "${{ github.event.inputs.AdmobAppKey }}" "${{ github.event.inputs.ApplovinAppKey }}" | ||
./gradlew sample-kotlin:assembleRelease | ||
- name: Upload Release Build to Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: release-artifacts | ||
path: sample-kotlin/build/outputs/apk/release/*universal-release*.apk | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
sample-kotlin/src/main/java/ir/tapsell/sample/appopen/AppOpenFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package ir.tapsell.sample.appopen | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.viewModels | ||
import androidx.lifecycle.lifecycleScope | ||
import ir.tapsell.sample.databinding.FragmentInterstitialBinding | ||
import ir.tapsell.shared.AdmobKeys | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
class AppOpenFragment : Fragment() { | ||
|
||
private var _binding: FragmentInterstitialBinding? = null | ||
private val binding get() = _binding!! | ||
private val viewModel by viewModels<AppOpenViewModel>() | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
_binding = FragmentInterstitialBinding.inflate(inflater, container, false) | ||
return _binding?.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.inputZone.setText(AdmobKeys.APP_OPEN) | ||
binding.btnRequest.setOnClickListener { | ||
requestAd() | ||
} | ||
binding.btnShow.setOnClickListener { | ||
showAd() | ||
} | ||
|
||
lifecycleScope.launch(Dispatchers.Main) { | ||
viewModel.logMessage.collect { | ||
binding.tvLog.text = it | ||
} | ||
} | ||
} | ||
|
||
private fun requestAd() { | ||
viewModel.requestAd(binding.inputZone.text.toString()) | ||
} | ||
|
||
private fun showAd() { | ||
viewModel.showAd(requireActivity()) | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
_binding = null | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
sample-kotlin/src/main/java/ir/tapsell/sample/appopen/AppOpenViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package ir.tapsell.sample.appopen | ||
|
||
import android.util.Log | ||
import androidx.fragment.app.FragmentActivity | ||
import ir.tapsell.mediation.Tapsell | ||
import ir.tapsell.mediation.ad.AdStateListener | ||
import ir.tapsell.mediation.ad.request.RequestResultListener | ||
import ir.tapsell.mediation.ad.show.AdShowCompletionState | ||
import ir.tapsell.sample.BaseViewModel | ||
|
||
class AppOpenViewModel : BaseViewModel() { | ||
|
||
companion object { | ||
private const val TAG = "AppOpenViewModel" | ||
} | ||
|
||
var responseId: String? = null | ||
private set | ||
|
||
|
||
fun requestAd(zoneId: String) { | ||
Tapsell.requestAppOpenAd(zoneId, object : RequestResultListener { | ||
override fun onFailure() { | ||
log(TAG, "onFailure", Log.ERROR) | ||
} | ||
|
||
override fun onSuccess(adId: String) { | ||
responseId = adId | ||
log(TAG, "onSuccess: $adId") | ||
} | ||
}) | ||
} | ||
|
||
fun showAd(activity: FragmentActivity) { | ||
if (responseId.isNullOrEmpty()) { | ||
log(TAG, "adId is empty", Log.ERROR) | ||
return | ||
} | ||
Tapsell.showAppOpenAd(responseId, activity, object : AdStateListener.AppOpen { | ||
override fun onAdClicked() { | ||
log(TAG, "onAdClicked") | ||
} | ||
|
||
override fun onAdClosed(completionState: AdShowCompletionState) { | ||
log(TAG, "onAdClosed: ${completionState.name}") | ||
} | ||
|
||
override fun onAdFailed(message: String) { | ||
log(TAG, "onAdFailed: $message", Log.ERROR) | ||
} | ||
|
||
override fun onAdImpression() { | ||
log(TAG, "onAdImpression") | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:padding="@dimen/space_small" | ||
tools:context=".appopen.AppOpenFragment"> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/btn_request" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/request" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<com.google.android.material.button.MaterialButton | ||
android:id="@+id/btn_show" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginVertical="@dimen/space_small" | ||
android:text="@string/show" | ||
app:layout_constraintTop_toBottomOf="@+id/btn_request" /> | ||
|
||
<com.google.android.material.textview.MaterialTextView | ||
android:id="@+id/tv_log" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="12dp" | ||
android:layout_marginTop="12dp" | ||
android:layout_marginEnd="12dp" | ||
android:background="#ddd" | ||
android:padding="8dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@+id/btn_show" /> | ||
|
||
<com.google.android.material.textfield.TextInputEditText | ||
android:id="@+id/input_zone" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/zone_id" | ||
android:textColor="@android:color/darker_gray" | ||
android:textSize="@dimen/h6" | ||
android:textStyle="italic" | ||
app:layout_constraintBottom_toBottomOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.