From c6690ba50cebd68fce98a9a067ce0b54d2359394 Mon Sep 17 00:00:00 2001 From: turleo Date: Fri, 3 Jul 2020 15:33:38 +1000 Subject: [PATCH] About activity added --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 7 +- .../java/bem/ware/yoipis/AboutActivity.kt | 34 ++++++ .../main/java/bem/ware/yoipis/MainActivity.kt | 23 +++- app/src/main/res/layout/activity_about.xml | 112 ++++++++++++++++++ app/src/main/res/menu/menu_main.xml | 4 +- app/src/main/res/values/strings.xml | 8 ++ app/src/main/res/values/styles.xml | 5 + 8 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/bem/ware/yoipis/AboutActivity.kt create mode 100644 app/src/main/res/layout/activity_about.xml diff --git a/app/build.gradle b/app/build.gradle index 72b1e2e..06fbb03 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.google.android.material:material:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6bd31fd..cbdb806 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,13 +2,19 @@ + + + - \ No newline at end of file diff --git a/app/src/main/java/bem/ware/yoipis/AboutActivity.kt b/app/src/main/java/bem/ware/yoipis/AboutActivity.kt new file mode 100644 index 0000000..daea6d1 --- /dev/null +++ b/app/src/main/java/bem/ware/yoipis/AboutActivity.kt @@ -0,0 +1,34 @@ +package bem.ware.yoipis + +import android.content.ActivityNotFoundException +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.view.View +import androidx.appcompat.app.AppCompatActivity + +class AboutActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_about) + } + + fun onClick(v: View) { + when (v.id) { + R.id.google_play_link -> { + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=bem.ware.yoipis"))) + } catch (e: ActivityNotFoundException) { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=bem.ware.yoipis"))) + } + } + R.id.github -> { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/turleo/ip_checker"))) + } + R.id.author_github -> { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/turleo"))) + } + } + } +} diff --git a/app/src/main/java/bem/ware/yoipis/MainActivity.kt b/app/src/main/java/bem/ware/yoipis/MainActivity.kt index f493def..be747c1 100644 --- a/app/src/main/java/bem/ware/yoipis/MainActivity.kt +++ b/app/src/main/java/bem/ware/yoipis/MainActivity.kt @@ -4,9 +4,11 @@ import android.annotation.SuppressLint import android.content.ClipData import android.content.ClipboardManager import android.content.Context +import android.content.Intent import android.os.AsyncTask import android.os.Bundle -import android.util.Log +import android.view.Menu +import android.view.MenuItem import android.view.View import android.widget.ProgressBar import android.widget.TextView @@ -82,8 +84,6 @@ class MainActivity : AppCompatActivity() { while (`in`.readLine().also { inputLine = it } != null) ipis = inputLine `in`.close() } catch (e: Exception) { - val TAG = "NoAnyIP" - Log.wtf(TAG, e.toString()) Snackbar.make(view!!, e.toString(), Snackbar.LENGTH_SHORT) .setAction("Action", null).show() } @@ -98,4 +98,21 @@ class MainActivity : AppCompatActivity() { Snackbar.make(view!!, "Copied", Snackbar.LENGTH_SHORT) .setAction("Action", null).show() } + + + override fun onCreateOptionsMenu(menu: Menu?): Boolean { + val inflater = menuInflater + inflater.inflate(R.menu.menu_main, menu) + return super.onCreateOptionsMenu(menu) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.about -> { + startActivity(Intent(this, AboutActivity::class.java)) + return true + } + } + return super.onOptionsItemSelected(item) + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml new file mode 100644 index 0000000..9098b2a --- /dev/null +++ b/app/src/main/res/layout/activity_about.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 310e0f1..80199a0 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -1,6 +1,8 @@ + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 24de964..c5c3c28 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,4 +2,12 @@ IP checker Settings IP is coming… + About + by turleo + Project is using: + Logo + - Firebase + Rate this app 5 stars + GitHub + Author\'s GitHub diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0bda8c9..38fb796 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -17,4 +17,9 @@ +