44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class AppVersionController extends Controller
|
|
{
|
|
/**
|
|
* Return the latest Android app version info.
|
|
*
|
|
* To publish a new version:
|
|
* 1. Build a signed APK in Android Studio.
|
|
* 2. Rename it to the android_app.apk_file name in the platform config, e.g. timebank-cc-1.0.1.apk.
|
|
* 3. Upload it to storage/app/public/apk/.
|
|
* 4. Update $versionCode and $versionName below.
|
|
* 5. Run: php artisan storage:link (once, if not already done)
|
|
*/
|
|
public function show(): JsonResponse
|
|
{
|
|
abort_unless(timebank_config('android_app.enabled', true), 404);
|
|
|
|
return response()->json(self::latest());
|
|
}
|
|
|
|
/**
|
|
* The latest version and its download URL; also used by the static Android app page.
|
|
* scripts/deploy-apk.sh rewrites the two version lines below.
|
|
*/
|
|
public static function latest(): array
|
|
{
|
|
$versionCode = 6;
|
|
$versionName = '1.0.4';
|
|
|
|
$apkFile = str_replace('{version}', $versionName, timebank_config('android_app.apk_file', 'timebank-cc-{version}.apk'));
|
|
|
|
return [
|
|
'versionCode' => $versionCode,
|
|
'versionName' => $versionName,
|
|
'apkUrl' => url("storage/apk/{$apkFile}"),
|
|
];
|
|
}
|
|
}
|