Skip to content

Commit

Permalink
About activity added
Browse files Browse the repository at this point in the history
  • Loading branch information
turleo committed Jul 3, 2020
1 parent b85d510 commit c6690ba
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="bem.ware.yoipis">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".AboutActivity"
android:theme="@style/AppTheme.Dialog" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Expand All @@ -20,6 +26,5 @@
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />

</manifest>
34 changes: 34 additions & 0 deletions app/src/main/java/bem/ware/yoipis/AboutActivity.kt
Original file line number Diff line number Diff line change
@@ -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")))
}
}
}
}
23 changes: 20 additions & 3 deletions app/src/main/java/bem/ware/yoipis/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}
Expand All @@ -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)
}
}
112 changes: 112 additions & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".AboutActivity">

<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/Logo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_launcher_foreground" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@color/text"
android:textSize="36sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/by_turleo"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/using"
android:textColor="@color/text"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />

<TextView
android:id="@+id/textView5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/dependences"
android:textAlignment="viewStart"
android:textColor="@color/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.489"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView4" />

<TextView
android:id="@+id/google_play_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:onClick="onClick"
android:text="@string/rate_us_5_stars"
android:textColor="@color/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5" />

<TextView
android:id="@+id/author_github"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="onClick"
android:text="@string/author_github"
android:textColor="@color/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/github" />

<TextView
android:id="@+id/github"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:onClick="onClick"
android:text="@string/github"
android:textColor="@color/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/google_play_link" />

<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/author_github" />

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 3 additions & 1 deletion app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="bem.ware.yoipis.MainActivity">

<item
android:id="@+id/about"
android:title="@string/about" />
</menu>
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
<string name="app_name">IP checker</string>
<string name="action_settings">Settings</string>
<string name="loading_text">IP is coming…</string>
<string name="about">About</string>
<string name="by_turleo">by turleo</string>
<string name="using">Project is using:</string>
<string name="Logo">Logo</string>
<string name="dependences">- Firebase</string>
<string name="rate_us_5_stars">Rate this app 5 stars</string>
<string name="github">GitHub</string>
<string name="author_github">Author\'s GitHub</string>
</resources>
5 changes: 5 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

<style name="AppTheme.Dialog" parent="Theme.AppCompat.DayNight.Dialog">
<item name="android:windowMinWidthMajor">97%</item>
<item name="android:windowMinWidthMinor">97%</item>
</style>

</resources>

0 comments on commit c6690ba

Please sign in to comment.