Fix android app configuration and refactor keystore generation and update docs on building

pull/98/head
James Mills 2 years ago
parent 21446a3de0
commit c9202b73ad
Signed by: prologic
GPG Key ID: AC4C014F1440EBD6

2
.gitignore vendored

@ -45,6 +45,8 @@ app.*.map.json
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
*.jks
.envrc
keys/
goryon-secrets/

@ -1,5 +1,6 @@
MIT License
Copyright (c) 2021-present Yarn.social
Copyright (c) 2020 Daven Casia
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -18,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.

@ -1,18 +1,29 @@
# goryon 🐦🐦🐦
A flutter client for twtxt
# Goryon 🐦🐦🐦
A [Flutter](https://flutter.dev) client for the [Yarn.social] Pod API.
## Install it
- 🤖 [Play Store](https://play.google.com/store/apps/details?id=com.jointwtxt.goryon)
- 🍏 [App Store](https://apps.apple.com/us/app/id1528871748)
- 🤖 [Play Store](#TBD)
- 🍏 [App Store](#TBD)
## Requirements
- [Install flutter](https://flutter.dev/docs/get-started/install)
- [Setup your editor (optional)](https://flutter.dev/docs/get-started/editor?tab=androidstudio)
## Running the app
1. Run your iOS simulator or Android emulator
2. **flutter pub get**
3. **flutter run**
- [Install Flutter](https://flutter.dev/docs/get-started/install)
- [Setup your Editor (optional)](https://flutter.dev/docs/get-started/editor?tab=androidstudio)
## Buildingg the app
- Run your iOS simulator or Android emulator
- `flutter pub get`
- `flutter run`
### Building for Android
- Setup a keystore: `./scripts/generate-keystore.sh`
- Setup the `key.properties`: `./scripts/set-key-properties.sh`
It is recommended ot use [direnv](https://github.com/direnv/direnv) if you can.
## Screenshots
@ -21,7 +32,7 @@ A flutter client for twtxt
![Drawer](https://user-images.githubusercontent.com/15314237/93292676-4ce49480-f7a3-11ea-8a74-e54ccee3c8cf.png)
## Building
Refer to flutter official docs
- [iOS](https://flutter.dev/docs/deployment/ios)
- [Android](https://flutter.dev/docs/deployment/android)
## License
Goryon is licensed under ther terms of the [MIT License](/LICENSE) and is a
part of the the [Yarn.social](https://yarn.social) project.

@ -1,64 +0,0 @@
#!/bin/sh
if ! test -f ./android/app/upload-keystore.jks
then
if test -f ./android/key.properties; then rm ./android/key.properties; fi
echo "**No keystore found, so we'll need to generate one.**"
echo ""
echo "Please enter a password for the keystore (a least 6 characters):"
stty_orig=$(stty -g)
stty -echo
read ANDROID_KEY_STORE_PWD
stty $stty_orig
echo "Now please enter a password for the certificate key (at least 6 characters):"
stty_orig=$(stty -g)
stty -echo
read ANDROID_KEY_PWD
stty $stty_orig
echo "Generating keystore... please follow the prompts"
echo ""
keytool -genkey -v -keystore ./android/app/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload -storepass $ANDROID_KEY_STORE_PWD -keypass $ANDROID_KEY_PWD
fi
if ! test -f ./android/key.properties
then
if test -z "${ANDROID_KEY_STORE_PWD}"
then
echo "Please enter keystore password:"
stty_orig=$(stty -g)
stty -echo
read ANDROID_KEY_STORE_PWD
stty $stty_orig
fi
if test -z "${ANDROID_KEY_PWD}"
then
echo "Please enter certificate key password:"
stty_orig=$(stty -g)
stty -echo
read ANDROID_KEY_PWD
stty $stty_orig
fi
ANDROID_KEY_STORE_PWD=$ANDROID_KEY_STORE_PWD ANDROID_KEY_PWD=$ANDROID_KEY_PWD ./scripts/setenv.sh || exit 1
fi
echo ""
echo "Now executing [flutter build apk]..."
flutter build apk
## Uncomment the below command if you wish for the file containing the passwords to be deleted post-build
## (requires re-entering keystore passwords when this script is run again)
#rm ./android/key.properties
exit 0

@ -46,7 +46,7 @@ android {
}
defaultConfig {
applicationId "com.jointwtxt.goryon"
applicationId "social.yarn.goryon"
minSdkVersion 18
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()

@ -1,7 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jointwtxt.goryon">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="social.yarn.goryon">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

@ -1,48 +1,30 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jointwtxt.goryon">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jointwtxt.goryon">
<uses-permission android:name="android.permission.INTERNET" />
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="Goryon"
android:icon="@mipmap/ic_launcher">
<activity
android:name="com.jointwtxt.goryon.MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<application android:name="io.flutter.app.FlutterApplication" android:label="Goryon" android:icon="@mipmap/ic_launcher">
<activity android:name="social.yarn.goryon.MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data android:name="flutterEmbedding" android:value="2" />
</application>
</manifest>

@ -1,7 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jointwtxt.goryon">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="social.yarn.goryon">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

@ -0,0 +1,38 @@
#!/bin/sh
random_string() {
n="${1:-32}"
tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$n" | head -n 1
}
if ! [ -f ./android/app/upload-keystore.jks ]; then
[ -f ./android/key.properties ] && rm ./android/key.properties
echo "No keystore found, generating a new one..."
echo
ANDROID_KEY_STORE_PWD="$(random_string 12)"
ANDROID_KEY_PWD="$(random_string 12)"
echo "Generating keystore... "
echo
keytool -v -alias upload -genkey -keyalg RSA -keysize 2048 -validity 10000 \
-keypass "$ANDROID_KEY_PWD" -storepass "$ANDROID_KEY_STORE_PWD" \
-keystore ./android/app/upload-keystore.jks
echo "Generating .envrc ..."
echo
{
printf "export ANDROID_KEY_STORE_PWD=%s\n" "$ANDROID_KEY_STORE_PWD"
printf "export ANDROID_KEY_PWD=%s\n" "$ANDROID_KEY_PWD"
} > .envrc
echo "Settings up key.properties ..."
echo
(
export ANDROID_KEY_STORE_PWD ANDROID_KEY_PWD
./scripts/set-key-properties.sh
) || exit 1
fi

@ -0,0 +1,22 @@
#!/bin/sh
if [ -z "${ANDROID_KEY_STORE_PWD}" ]; then
echo "ANDROID_KEY_STORE_PWD not found, abort"
exit 1
else
echo "ANDROID_KEY_STORE_PWD detected, proceeding..."
fi
if [ -z "${ANDROID_KEY_PWD}" ]; then
echo "ANDROID_KEY_PWD not found, abort"
exit 1
else
echo "ANDROID_KEY_PWD detected, proceeding..."
fi
{
echo "storePassword=${ANDROID_KEY_STORE_PWD}"
echo "keyPassword=${ANDROID_KEY_PWD}"
echo "keyAlias=upload"
echo "storeFile=upload-keystore.jks"
} >> android/key.properties

@ -1,33 +0,0 @@
#!/bin/sh
if [ -z "${ANDROID_KEY_STORE_PWD}" ]; then
echo "ANDROID_KEY_STORE_PWD not found, abort"
exit 1
else
echo "ANDROID_KEY_STORE_PWD detected, proceeding..."
fi
if [ -z "${ANDROID_KEY_PWD}" ]; then
echo "ANDROID_KEY_PWD not found, abort"
exit 1
else
echo "ANDROID_KEY_PWD detected, proceeding..."
fi
{
echo "storePassword=${ANDROID_KEY_STORE_PWD}"
echo "keyPassword=${ANDROID_KEY_PWD}"
echo "keyAlias=upload"
echo "storeFile=upload-keystore.jks"
} >> android/key.properties
## Below has been commented out by eldersnake@yarn.andrewjvpowell.com
## as we're generating the keystore in the android-build-wrapper.sh script
## Uncomment out the below if running this script on its own (and if you know how to set the below variables!)
#echo "${RELEASE_KEYSTORE}" > release.keystore.asc
#gpg -d --passphrase "${RELEASE_KEYSTORE_PASSPHRASE}" --batch release.keystore.asc > android/app/key.jks
#mkdir -p keys/android
#echo "${RELEASE_SERVICE_ACCOUNT_KEYSTORE}" > service_account.keystore.asc
#gpg -d --passphrase "${RELEASE_KEYSTORE_PASSPHRASE}" --batch service_account.keystore.asc > keys/android/service_account.json
Loading…
Cancel
Save