add build customization options (#1532)

This commit is contained in:
Konrad Pozniak 2019-10-29 20:30:46 +01:00 committed by GitHub
parent 47f2d1bf42
commit 83ced20e4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 69 additions and 14 deletions

View file

@ -3,6 +3,8 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: "../instance-build.gradle"
def getGitSha = { ->
def stdout = new ByteArrayOutputStream()
exec {
@ -15,7 +17,7 @@ def getGitSha = { ->
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.keylesspalace.tusky"
applicationId APP_ID
minSdkVersion 21
targetSdkVersion 29
versionCode 68
@ -23,6 +25,12 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
resValue "string", "app_name", APP_NAME
buildConfigField("String", "CUSTOM_LOGO_URL", "\"$CUSTOM_LOGO_URL\"")
buildConfigField("String", "CUSTOM_INSTANCE", "\"$CUSTOM_INSTANCE\"")
buildConfigField("String", "SUPPORT_ACCOUNT_URL", "\"$SUPPORT_ACCOUNT_URL\"")
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas")

View file

@ -12,6 +12,7 @@ import android.view.MenuItem
import android.widget.TextView
import com.keylesspalace.tusky.di.Injectable
import com.keylesspalace.tusky.util.CustomURLSpan
import com.keylesspalace.tusky.util.hide
import kotlinx.android.synthetic.main.activity_about.*
import kotlinx.android.synthetic.main.toolbar_basic.*
@ -29,14 +30,18 @@ class AboutActivity : BottomSheetActivity(), Injectable {
setTitle(R.string.about_title_activity)
versionTextView.text = getString(R.string.about_tusky_version, BuildConfig.VERSION_NAME)
versionTextView.text = getString(R.string.about_app_version, getString(R.string.app_name), BuildConfig.VERSION_NAME)
if(BuildConfig.CUSTOM_INSTANCE.isBlank()) {
aboutPoweredByTusky.hide()
}
aboutLicenseInfoTextView.setClickableTextWithoutUnderlines(R.string.about_tusky_license)
aboutWebsiteInfoTextView.setClickableTextWithoutUnderlines(R.string.about_project_site)
aboutBugsFeaturesInfoTextView.setClickableTextWithoutUnderlines(R.string.about_bug_feature_request_site)
tuskyProfileButton.setOnClickListener {
onAccountButtonClick()
viewUrl(BuildConfig.SUPPORT_ACCOUNT_URL)
}
aboutLicensesButton.setOnClickListener {
@ -45,10 +50,6 @@ class AboutActivity : BottomSheetActivity(), Injectable {
}
private fun onAccountButtonClick() {
viewUrl("https://mastodon.social/@Tusky")
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {

View file

@ -28,6 +28,7 @@ import android.view.MenuItem
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import com.bumptech.glide.Glide
import com.keylesspalace.tusky.di.Injectable
import com.keylesspalace.tusky.entity.AccessToken
import com.keylesspalace.tusky.entity.AppCredentials
@ -62,6 +63,18 @@ class LoginActivity : BaseActivity(), Injectable {
setContentView(R.layout.activity_login)
if(savedInstanceState == null && BuildConfig.CUSTOM_INSTANCE.isNotBlank() && !isAdditionalLogin()) {
domainEditText.setText(BuildConfig.CUSTOM_INSTANCE)
domainEditText.setSelection(BuildConfig.CUSTOM_INSTANCE.length)
}
if(BuildConfig.CUSTOM_LOGO_URL.isNotBlank()) {
Glide.with(loginLogo)
.load(BuildConfig.CUSTOM_LOGO_URL)
.placeholder(null)
.into(loginLogo)
}
preferences = getSharedPreferences(
getString(R.string.preferences_file_key), Context.MODE_PRIVATE)
@ -162,7 +175,7 @@ class LoginActivity : BaseActivity(), Injectable {
mastodonApi
.authenticateApp(domain, getString(R.string.app_name), oauthRedirectUri,
OAUTH_SCOPES, getString(R.string.app_website))
OAUTH_SCOPES, getString(R.string.tusky_website))
.enqueue(callback)
setLoading(true)
@ -174,9 +187,9 @@ class LoginActivity : BaseActivity(), Injectable {
val endpoint = MastodonApi.ENDPOINT_AUTHORIZE
val parameters = mapOf(
"client_id" to clientId,
"redirect_uri" to oauthRedirectUri,
"response_type" to "code",
"scope" to OAUTH_SCOPES
"redirect_uri" to oauthRedirectUri,
"response_type" to "code",
"scope" to OAUTH_SCOPES
)
val url = "https://" + domain + endpoint + "?" + toQueryString(parameters)
val uri = Uri.parse(url)
@ -336,7 +349,7 @@ class LoginActivity : BaseActivity(), Injectable {
.setToolbarColor(toolbarColor)
.build()
try {
customTabsIntent.launchUrl(context, uri)
customTabsIntent.launchUrl(context, uri)
} catch (e: ActivityNotFoundException) {
Log.w(TAG, "Activity was not found for intent $customTabsIntent")
return false

View file

@ -41,6 +41,18 @@
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/aboutPoweredByTusky"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawablePadding="16dp"
android:gravity="center_vertical"
android:textSize="18sp"
android:text="@string/about_powered_by_tusky"
android:textStyle="bold" />
<TextView
android:id="@+id/aboutLicenseInfoTextView"
android:layout_width="match_parent"

View file

@ -27,6 +27,7 @@
android:layout_height="178dp"
android:layout_marginBottom="50dp"
android:contentDescription="@null"
android:id="@+id/loginLogo"
app:srcCompat="@drawable/elephant_friend" />
<LinearLayout

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">Tusky</string>
<string name="app_website" translatable="false">https://tusky.app</string>
<string name="tusky_website" translatable="false">https://tusky.app</string>
<string name="about_app_version">%1$s %2$s</string>
<string name="oauth_scheme" translatable="false">oauth2redirect</string>
<string name="preferences_file_key" translatable="false">com.keylesspalace.tusky.PREFERENCES</string>

View file

@ -277,6 +277,7 @@
<string name="about_title_activity">About</string>
<string name="about_tusky_version">Tusky %s</string>
<string name="about_powered_by_tusky">Powered by Tusky</string>
<string name="about_tusky_license">Tusky is free and open-source software.
It is licensed under the GNU General Public License Version 3.
You can view the license here: https://www.gnu.org/licenses/gpl-3.0.en.html</string>

19
instance-build.gradle Normal file
View file

@ -0,0 +1,19 @@
/**
Edit this file to create a Tusky build that is customized for your Fediverse instance.
Note: Publishing a custom build on Google Play may violate the Google Play developer policy (Repetetive Content)
*/
// The app name
ext.APP_NAME = "Tusky"
// The application id. Must be unique, e.g. based on your domain
ext.APP_ID = "com.keylesspalace.tusky"
// url of a custom app logo. Recommended size at least 600x600. Keep empty to use the Tusky elephant friend.
ext.CUSTOM_LOGO_URL = ""
// e.g. mastodon.social. Keep empty to not suggest any instance on the signup screen
ext.CUSTOM_INSTANCE = ""
// link to your support account. Will be linked on the about page when not empty.
ext.SUPPORT_ACCOUNT_URL = "https://mastodon.social/@Tusky"