diff --git a/app/build.gradle b/app/build.gradle index a63d95dc5..4d422dda1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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") diff --git a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt index e66375dd9..ce7d7294a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/AboutActivity.kt @@ -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 -> { diff --git a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt index 69c1d42d7..b7f472738 100644 --- a/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/LoginActivity.kt @@ -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 diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 9bc43d641..2d55b693e 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -41,6 +41,18 @@ android:textSize="24sp" android:textStyle="bold" /> + + + - Tusky - https://tusky.app + https://tusky.app + %1$s %2$s oauth2redirect com.keylesspalace.tusky.PREFERENCES diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cff97ad37..24ed46f15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -277,6 +277,7 @@ About Tusky %s + Powered by Tusky 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 diff --git a/instance-build.gradle b/instance-build.gradle new file mode 100644 index 000000000..eec6fcac1 --- /dev/null +++ b/instance-build.gradle @@ -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" \ No newline at end of file