Skip to content

Commit

Permalink
#5 compatiblity check styling, success and failure icon
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-mausch committed Jan 7, 2018
1 parent 4c2777d commit 257c7d4
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
22 changes: 18 additions & 4 deletions app/src/main/java/de/neonew/mesh/android/frontend/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.neonew.mesh.android.frontend

import android.graphics.PorterDuff
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentStatePagerAdapter
import android.support.v4.content.ContextCompat
import android.support.v7.app.AppCompatActivity
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
import de.neonew.mesh.android.R
Expand All @@ -19,10 +21,22 @@ class MainActivity : AppCompatActivity() {

window.setSoftInputMode(SOFT_INPUT_STATE_HIDDEN)

compatibility_check.text = getString(when (runCompatiblityCheck()) {
true -> R.string.compatibility_check_success
false -> R.string.compatibility_check_failure
})
when (runCompatiblityCheck()) {
true -> {
compatibility_check.text = getString(R.string.compatibility_check_success)

val drawable = ContextCompat.getDrawable(this, R.drawable.ic_check_circle)
drawable.setColorFilter(ContextCompat.getColor(this, R.color.success), PorterDuff.Mode.MULTIPLY)
compatibility_check.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
}
false -> {
compatibility_check.text = getString(R.string.compatibility_check_failure)

val drawable = ContextCompat.getDrawable(this, R.drawable.ic_warn)
drawable.setColorFilter(ContextCompat.getColor(this, R.color.failure), PorterDuff.Mode.MULTIPLY)
compatibility_check.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
}
}

pager.adapter = TabPagerAdapter(supportFragmentManager)
tab_layout.setupWithViewPager(pager)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/border.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
android:shape="rectangle">

<solid android:color="@android:color/white"/>
<stroke android:width="3dp" android:color="#ffa500"/>
<stroke android:width="1dp" android:color="#666666"/>

</shape>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/ic_check_circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path android:fillColor="#ffffff"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z"/>
</vector>
8 changes: 8 additions & 0 deletions app/src/main/res/drawable/ic_warn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path android:fillColor="#ffffff"
android:pathData="M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z"/>
</vector>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:orientation="vertical">
<TextView
android:id="@+id/compatibility_check"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/border"
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorPrimary">#3f51b5</color>
<color name="colorPrimaryDark">#303f9f</color>
<color name="colorAccent">#ff4081</color>
<color name="success">#4bab4d</color>
<color name="failure">#d65e5e</color>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<string name="run_olsrd">Run OLSRD</string>
<string name="kill_olsrd">Kill</string>
<string name="force_kill_olsrd">Force Kill</string>
<string name="compatibility_check_success">Your phone works with MeshAndroid!</string>
<string name="compatibility_check_success">Your phone is compatible with MeshAndroid.</string>
<string name="compatibility_check_failure">Sorry, but your phone is not supported. :(</string>
</resources>

0 comments on commit 257c7d4

Please sign in to comment.