Skip to content

Commit

Permalink
Merge pull request #2 from lscambo13/dev
Browse files Browse the repository at this point in the history
Contactless for WhatsApp v3.1

Fixed ripple effects
Corrected typos
Fixed exit functionality previously broken
Better easter eg.
  • Loading branch information
lscambo13 authored Feb 1, 2021
2 parents 04cfdbd + 413bb47 commit cd155a0
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 26 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
minSdkVersion 21
targetSdkVersion 30
// Version 2.1 = 7
versionCode 8
versionName '3.0'
versionCode 9
versionName '3.1'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs "en"
}
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/lscambo13/contactlessForWhatsApp/About.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.content.ContextCompat
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdView
import kotlinx.android.synthetic.main.activity_about.*
import kotlin.system.exitProcess

class About : AppCompatActivity() {

Expand Down Expand Up @@ -94,6 +96,14 @@ class About : AppCompatActivity() {
builder.setMessage(R.string.easterEggMessage)
builder.setPositiveButton("Cheers") { _, _ ->
}
when (Preferences(this).getEasterEgg()) {
false -> {
builder.setNeutralButton("") { _, _ ->
Preferences(this).setEasterEgg(true)
}
builder.setNeutralButtonIcon(ContextCompat.getDrawable(this, R.drawable.egg))
}
}
val alertDialog: AlertDialog = builder.create()
alertDialog.setCancelable(false)
alertDialog.show()
Expand Down Expand Up @@ -145,8 +155,8 @@ class About : AppCompatActivity() {
true
}
R.id.exit -> {
finish()
true
this.finish()
exitProcess(0)
}
R.id.home -> {
Menu.MenuClicks.home(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdView
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*
import kotlin.system.exitProcess

open class MainActivity : AppCompatActivity() {

Expand Down Expand Up @@ -220,8 +221,8 @@ open class MainActivity : AppCompatActivity() {
true
}
R.id.exit -> {
finish()
true
this.finish()
exitProcess(0)
}
R.id.about -> {
Menu.MenuClicks.about(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ import androidx.appcompat.app.AppCompatDelegate

class Preferences(context: Context) {

// Theme settings begin. --------------------------------

// This is the save file for theme settings.
val preferenceThemeFile = "ConfigTheme"

// This is the integer entry for theme style.
val preferenceIDTheme = "CurrentTheme"

// This is the save file for detecting first run.
val preferenceFirstRunFile = "ConfigFirstRun"

// This is the integer entry for first run.
val preferenceIDFirstRun = "FirstRun"

// This reads the theme file, ConfigTheme,
// and reads the presently set theme style from CurrentTheme. (default = set by system)
//
Expand All @@ -32,6 +28,24 @@ class Preferences(context: Context) {
return preferenceTheme.getInt(preferenceIDTheme, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
}

// This saves the set theme as -1, 1 or 2.
fun setCurrentTheme(theme: Int) {
val editor = preferenceTheme.edit()
editor.putInt(preferenceIDTheme, theme)
editor.apply()
}

// Theme settings end. --------------------------------


// First run settings begin. --------------------------

// This is the save file for detecting first run.
val preferenceFirstRunFile = "ConfigFirstRun"

// This is the integer entry for first run.
val preferenceIDFirstRun = "FirstRun"

// This reads the first run detection file, ConfigFirstRun,
// and detects if the app is installed freshly (Int 0) or updated (Int !0) from entry FirstRun.
val preferenceFirstRun: SharedPreferences =
Expand All @@ -41,17 +55,40 @@ class Preferences(context: Context) {
return preferenceFirstRun.getInt(preferenceIDFirstRun, 0)
}

// This saves the set theme as -1, 1 or 2.
fun setCurrentTheme(theme: Int) {
val editor = preferenceTheme.edit()
editor.putInt(preferenceIDTheme, theme)
editor.apply()
}

// This saves the first run property as 0 or VersionCode.
fun setFirstRun(run: Int) {
val editor = preferenceFirstRun.edit()
editor.putInt(preferenceIDFirstRun, run)
editor.apply()
}

// First run settings end. --------------------------


// Easter egg settings begin. -----------------------

// This is the save file for collecting easter egg.
val preferenceEasterEggFile = "ConfigEasterEgg"

// This is the integer entry for easter egg.
val preferenceIDEasterEgg = "EasterEgg"

// This reads the easter egg collection file, ConfigEasterEgg,
// and detects if the egg is collected (true) or not (false) from entry EasterEgg.
val preferenceEasterEgg: SharedPreferences =
context.getSharedPreferences(preferenceEasterEggFile, Context.MODE_PRIVATE)

fun getEasterEgg(): Boolean {
return preferenceEasterEgg.getBoolean(preferenceIDEasterEgg, false)
}

// This saves the easter egg property as true or false.
fun setEasterEgg(collected: Boolean) {
val editor = preferenceEasterEgg.edit()
editor.putBoolean(preferenceIDEasterEgg, collected)
editor.apply()
}

// Easter egg settings end. -----------------------

}
Binary file added app/src/main/res/drawable/egg.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="36dp"

android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:contentDescription="Share"
Expand Down Expand Up @@ -198,6 +197,7 @@
android:elevation="12dp"
android:focusable="true"
android:padding="4dp"
android:theme="@style/Highlight"
app:layout_constraintEnd_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/menu"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,12 @@
android:elevation="12dp"
android:focusable="true"
android:padding="4dp"
android:theme="@style/Highlight"
app:layout_constraintEnd_toEndOf="@+id/textView2"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/menu"
app:tint="@color/colorText"
app:tintMode="src_in"
app:tintMode="src_atop"
tools:ignore="ContentDescription" />

</androidx.constraintlayout.widget.ConstraintLayout>
10 changes: 10 additions & 0 deletions app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="statusBarBackground">@android:color/transparent</item>
<item name="colorPrimary">@color/colorPrimary</item>
Expand Down Expand Up @@ -31,4 +32,13 @@
<item name="android:textAppearanceLarge">@font/din</item>
<item name="android:fontFamily">@font/din</item>
</style>

<style name="MenuTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- so empty -->
</style>

<style name="Highlight" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorControlHighlight">#40161a23</item>
</style>

</resources>
8 changes: 4 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<string name="about">About</string>
<string name="home">Home</string>
<string name="changelog">Changelog</string>
<string name="version">Version 3.0</string>
<string name="version">Version 3.1</string>
<string name="welcomeTitle">Hi there!</string>
<string name="easterEggTitle">You found the secret!</string>
<string name="easterEggMessage">You must be related to Sherlock Holmes. We thank you for staying invested in our first app.\n\nDo you like the dark mode and animations?\nWe hope you enjoy this app and share your feedback.</string>
<string name="easterEggMessage">You must be related to Sherlock Holmes. We thank you for staying invested in our first app.\n\nDo you like the dark mode and animations? We hope you enjoy this app and share your feedback.</string>
<string name="welcomeMessage">It\'s lscambo13. I Thank you for installing our first app.\n\nThe app features full dark mode and nice animations. You should also take a look at the source code and the latest changes in version 3.0 from the three-dot menu at top-right corner.\n\nWe hope you enjoy this app and share your feedback at our Telegram support group.</string>
<string name="updateTitle">What\'s New in v3.0</string>
<string name="updateMessage">1. Better theme in three-dot menu on the top-right corner\n2. Fixed crashes on certain in the About screen\n3. All new welcome and changelog dialogs\n4. Numerous under-the-hood improvements and the source code is now much easy to follow\n5. An easter egg. Can you find it?-\n\nCheck GitHub for more comprehensive list</string>
<string name="updateTitle">What\'s New in v3.1</string>
<string name="updateMessage">1. Better theme in three-dot menu on the top-right corner\n2. Fixed crashes in the About screen\n3. All new welcome and changelog dialogs\n4. An easter egg. Can you find it?\n5. Numerous under-the-hood improvements and bug fixes\n6. The source code is now much easy to follow\n\nCheck GitHub for more comprehensive list</string>
<string name="about_text">\n\nVersion 3.0\nFree software under GNU GPL v3.0\n\nAn app to let you chat with others on WhatsApp without ever needing to actually save their phone number in contacts.\n\nCreated by:\nLSCAMBO13 and MSC24X\n\n</string>
<string name="update">Check for updates</string>
<string name="main_ads">ca-app-pub-2978500497338722/8267326157</string>
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="statusBarBackground">@android:color/transparent</item>
<item name="colorPrimary">@color/colorPrimary</item>
Expand All @@ -8,7 +9,7 @@
<item name="android:windowLightNavigationBar" tools:ignore="NewApi">true</item>
<item name="android:navigationBarColor">@color/colorPrimary</item>
<item name="android:windowBackground">@color/colorPrimary</item>
<item name="fontFamily"> @font/din</item>
<item name="fontFamily">@font/din</item>
<!-- This will override the Alert Dialog theme -->
<item name="alertDialogTheme">@style/MyAlertDialogTheme</item>
</style>
Expand All @@ -33,7 +34,11 @@
</style>

<style name="MenuTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- so empty -->
</style>

<style name="Highlight" parent="@style/Theme.AppCompat.Light.NoActionBar">
<!-- item name="colorControlHighlight">#4007b77c</item -->
</style>

</resources>

0 comments on commit cd155a0

Please sign in to comment.