add Licences section

This commit is contained in:
tibbi 2016-08-07 16:03:09 +02:00
parent d4fe07cd76
commit 48c9496054
5 changed files with 82 additions and 7 deletions

View File

@ -21,5 +21,10 @@
android:name=".activities.AboutActivity"
android:label="@string/about"
android:parentActivityName=".activities.MainActivity"/>
<activity
android:name=".activities.LicenseActivity"
android:label="@string/third_party_licences"
android:parentActivityName=".activities.AboutActivity"/>
</application>
</manifest>

View File

@ -1,6 +1,7 @@
package com.simplemobiletools.applauncher.activities
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.text.Html
@ -21,9 +22,10 @@ class AboutActivity : AppCompatActivity() {
setContentView(R.layout.activity_about)
setupEmail()
setupCopyright()
setupRateUs()
setupLicense()
setupSocial()
setupCopyright()
}
private fun setupEmail() {
@ -34,12 +36,6 @@ class AboutActivity : AppCompatActivity() {
about_email.movementMethod = LinkMovementMethod.getInstance()
}
private fun setupCopyright() {
val versionName = BuildConfig.VERSION_NAME
val year = Calendar.getInstance().get(Calendar.YEAR)
about_copyright.text = String.format(getString(R.string.copyright), versionName, year)
}
private fun setupRateUs() {
if (preferences().isFirstRun) {
about_rate_us.visibility = View.GONE
@ -50,6 +46,12 @@ class AboutActivity : AppCompatActivity() {
}
}
private fun setupLicense() {
about_license.setOnClickListener {
startActivity(Intent(applicationContext, LicenseActivity::class.java))
}
}
private fun setupSocial() {
about_facebook.setOnClickListener {
startActivity(viewIntent(getFacebookUrl()))
@ -61,6 +63,12 @@ class AboutActivity : AppCompatActivity() {
}
}
private fun setupCopyright() {
val versionName = BuildConfig.VERSION_NAME
val year = Calendar.getInstance().get(Calendar.YEAR)
about_copyright.text = String.format(getString(R.string.copyright), versionName, year)
}
private fun getFacebookUrl(): String {
try {
packageManager.getPackageInfo("com.facebook.katana", 0)

View File

@ -0,0 +1,19 @@
package com.simplemobiletools.applauncher.activities
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.extensions.viewIntent
import kotlinx.android.synthetic.main.activity_license.*
class LicenseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_license)
license_kotlin_title.setOnClickListener {
startActivity(viewIntent(getString(R.string.kotlin_url)))
}
}
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/license_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/license"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/activity_margin">
<TextView
android:id="@+id/license_notice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/notice"/>
<TextView
android:id="@+id/license_kotlin_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin"
android:text="@string/kotlin_title"
android:textColor="@color/colorPrimary"/>
<TextView
android:id="@+id/license_kotlin_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/kotlin_text"/>
</LinearLayout>
</ScrollView>

View File

@ -14,4 +14,11 @@
<!-- Settings -->
<string name="settings">Settings</string>
<string name="dark_theme">Dark theme</string>
<!-- License -->
<string name="notice">This app uses the following third party libraries to make my life easier. Thank you.</string>
<string name="third_party_licences">Third party licences</string>
<string name="kotlin_title"><u>Kotlin (programming language)</u></string>
<string name="kotlin_text" translatable="false">Copyright 2010 - 2016 JetBrains s.r.o.\n\nLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions and limitations under the License.</string>
<string name="kotlin_url" translatable="false">https://github.com/JetBrains/kotlin</string>
</resources>