1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

Separate PlayStore version and normal version.

This commit is contained in:
Koen 2023-06-20 14:48:43 +02:00
parent e5c3b28a35
commit 9e9add1d96
7 changed files with 94 additions and 51 deletions

View file

@ -1,5 +1,6 @@
stages:
- buildAndDeployApk
- buildAndDeployPlayStoreAab
variables:
ANDROID_VERSION_NAME:
@ -18,4 +19,19 @@ buildAndDeployApk:
- ./gradlew --stacktrace assembleRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE
- cp ./app/build/outputs/apk/release/app-release.apk /var/www/html/fcast-release.apk
- cp ./app/build/outputs/apk/release/app-release.apk /var/www/html/fastcast-release.apk
- echo $ANDROID_VERSION_CODE > /var/www/html/fastcast-version.txt
- echo $ANDROID_VERSION_CODE > /var/www/html/fcast-version.txt
when: manual
buildAndDeployPlayStoreAab:
stage: buildAndDeployPlayStoreAab
before_script:
- cd receivers/android
script:
- if [ -z "$ANDROID_VERSION_NAME" ] || [ -z "$ANDROID_VERSION_CODE" ]; then echo "Version name or code not specified. Skipping build."; exit 0; fi
- ./gradlew --stacktrace assemblePlaystoreRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE
- cp ./app/build/outputs/apk/release/app-release.apk /var/www/html/fcast-release.apk
- cp ./app/build/outputs/apk/release/app-release.apk /var/www/html/fastcast-release.apk
- echo $ANDROID_VERSION_CODE > /var/www/html/fastcast-version.txt
- echo $ANDROID_VERSION_CODE > /var/www/html/fcast-version.txt
when: manual

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -32,6 +32,20 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
flavorDimensions "type"
productFlavors {
playstore {
dimension "type"
applicationIdSuffix ".playstore"
versionNameSuffix "-playstore"
buildConfigField "boolean", "IS_PLAYSTORE_VERSION", "true"
}
defaultFlavor {
dimension "type"
buildConfigField "boolean", "IS_PLAYSTORE_VERSION", "false"
}
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
@ -41,6 +55,12 @@ android {
}
}
sourceSets {
playstore {
manifest.srcFile 'src/playstore/AndroidManifest.xml'
}
}
buildTypes {
release {
signingConfig signingConfigs.release

View file

@ -6,7 +6,6 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application

View file

@ -31,6 +31,7 @@ class MainActivity : AppCompatActivity() {
private lateinit var _textIPs: TextView
private lateinit var _textProgress: TextView
private lateinit var _updateSpinner: ImageView
private lateinit var _layoutUpdate: LinearLayout;
private var _updating: Boolean = false
private val _scope: CoroutineScope = CoroutineScope(Dispatchers.Main)
@ -44,10 +45,10 @@ class MainActivity : AppCompatActivity() {
_textIPs = findViewById(R.id.text_ips)
_textProgress = findViewById(R.id.text_progress)
_updateSpinner = findViewById(R.id.update_spinner)
_layoutUpdate = findViewById(R.id.layout_update)
_text.text = getString(R.string.checking_for_updates)
_buttonUpdate.visibility = View.INVISIBLE
(_updateSpinner.drawable as Animatable?)?.start()
_buttonUpdate.setOnClickListener {
if (_updating) {
@ -58,8 +59,18 @@ class MainActivity : AppCompatActivity() {
update()
}
_scope.launch(Dispatchers.IO) {
checkForUpdates()
if (BuildConfig.IS_PLAYSTORE_VERSION) {
_layoutUpdate.visibility = View.GONE
_updateSpinner.visibility = View.GONE
(_updateSpinner.drawable as Animatable?)?.stop()
} else {
_layoutUpdate.visibility = View.VISIBLE
_updateSpinner.visibility = View.VISIBLE
(_updateSpinner.drawable as Animatable?)?.start()
_scope.launch(Dispatchers.IO) {
checkForUpdates()
}
}
_textIPs.text = "IPs\n" + getIPs().joinToString("\n") + "\n\nPort\n46899"
@ -177,6 +188,8 @@ class MainActivity : AppCompatActivity() {
}
private suspend fun checkForUpdates() {
Log.i(TAG, "Checking for updates...");
withContext(Dispatchers.IO) {
try {
val latestVersion = downloadVersionCode()

View file

@ -1,13 +0,0 @@
package com.futo.fcast.receiver
import android.content.Context
import android.util.Log
import android.widget.Toast
import kotlinx.coroutines.*
import okhttp3.OkHttpClient
class Updater {
companion object {
}
}

View file

@ -66,47 +66,56 @@
android:textSize="12dp"
tools:text="123" />
<TextView
android:id="@+id/text_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/there_is_an_update_available_do_you_wish_to_update"
android:textSize="14sp"
android:minLines="3"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular"
android:layout_marginTop="30dp"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:gravity="center"/>
<LinearLayout
android:id="@+id/layout_update"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="28dp"
android:layout_marginBottom="28dp">
android:orientation="vertical"
android:gravity="center">
<LinearLayout
android:id="@+id/button_update"
<TextView
android:id="@+id/text_dialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/background_button_primary"
android:layout_marginEnd="28dp"
android:clickable="true">
android:text="@string/there_is_an_update_available_do_you_wish_to_update"
android:textSize="14sp"
android:minLines="3"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular"
android:layout_marginTop="30dp"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:gravity="center"/>
<TextView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="28dp"
android:layout_marginBottom="28dp">
<LinearLayout
android:id="@+id/button_update"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/update"
android:textSize="14sp"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="28dp"
android:paddingEnd="28dp"/>
android:background="@drawable/background_button_primary"
android:layout_marginEnd="28dp"
android:clickable="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/update"
android:textSize="14sp"
android:textColor="@color/white"
android:fontFamily="@font/inter_regular"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingStart="28dp"
android:paddingEnd="28dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>