Skip to content

Commit

Permalink
Version free y paid
Browse files Browse the repository at this point in the history
  • Loading branch information
Ange1D committed Aug 12, 2021
1 parent abc0a6c commit 01f6a4f
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 9 deletions.
24 changes: 23 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,31 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

flavorDimensions 'price'

productFlavors{
free{
dimension "price"
resValue "string", "app_name", "Chrono Master Free"
applicationIdSuffix ".free"
versionNameSuffix "-free"
}
paid{
applicationId "com.equipo22.agenda.paid"
dimension "price"
resValue "string", "app_name", "Chrono Master Paid"
versionNameSuffix "-full"
}
}

buildTypes {
debug{
applicationIdSuffix ".debug"
debuggable true
}
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Expand Down
74 changes: 74 additions & 0 deletions app/src/free/java/com/equipo22/agenda/AdsFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.equipo22.agenda

import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Toast
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import com.google.android.material.button.MaterialButton
import com.google.android.material.dialog.MaterialAlertDialogBuilder


class AdsFragment : Fragment() {

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_ads, container, false)

val btnPaid = view.findViewById<MaterialButton>(R.id.btnPaid)
val LinearAds = view.findViewById<LinearLayout>(R.id.LinearAds)


loop()


btnPaid.setOnClickListener {

MaterialAlertDialogBuilder(requireActivity())
.setTitle(resources.getString(R.string.compra_dialog_title))
.setMessage(
resources.getString(
R.string.compra_dialog
)
)
.setPositiveButton(resources.getString(R.string.accept)) { dialog, which ->
Toast.makeText(requireActivity(),getString(R.string.paidOut), Toast.LENGTH_SHORT).show()
LinearAds.visibility=View.GONE
}
.setNegativeButton(resources.getString(R.string.btnCancel)) { dialog, which ->
}
.show()

}
return view
}

fun loop(){
Handler(Looper.getMainLooper()).postDelayed({
anuncios((0..2).random())
loop()
}, 3000)
}
fun anuncios(n:Int){
val imageAds = view?.findViewById<ImageView>(R.id.imageAds)
when(n){
0->imageAds?.setImageResource(R.drawable.ads_becas)
1 ->imageAds?.setImageResource(R.drawable.ads_mexico)
2 -> imageAds?.setImageResource(R.drawable.ads_sale)
else ->imageAds?.setImageResource(R.drawable.ads_becas)
}
}


}
25 changes: 25 additions & 0 deletions app/src/free/res/layout/fragment_ads.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="100dp"
tools:context=".AdsFragment"
android:background="@color/white"
android:id="@+id/LinearAds">

<ImageView
android:id="@+id/imageAds"
android:layout_width="271dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ads_becas" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnPaid"
style="@style/ChronoMasterTheme.Button"
android:layout_gravity="center"
android:layout_weight="1"
android:text="@string/adsButton" />

</LinearLayout>
6 changes: 6 additions & 0 deletions app/src/free/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<string name="adsButton">Quitar anuncios</string>
<string name="compra_dialog_title">Eliminar anuncios</string>
<string name="compra_dialog">¿Está seguro que desea comprar la version premium por $10?</string>
<string name="paidOut">Gracias por su compra</string>
</resources>
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:allowBackup="true"
android:fullBackupContent="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/appName"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/ChronoMasterTheme">
Expand Down
Binary file added app/src/main/res/drawable/ads_becas.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ads_mexico.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/ads_sale.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 21 additions & 3 deletions app/src/main/res/layout/activity_tarea_management.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/fragment_container"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" />
xmlns:android="http://schemas.android.com/apk/res/android" >

<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="0dp" />

<fragment
android:id="@+id/fragmentAds"
class="com.equipo22.agenda.AdsFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/fragment_ads.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
tools:context=".tareas.TareaManagementActivity">

</LinearLayout>

3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_agregar_tarea.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
android:id="@+id/btnCancel"
style="@style/ChronoMasterTheme.Button"
android:text="@string/btnCancel"
app:cornerRadius="20dp" />
app:cornerRadius="20dp"
android:layout_marginBottom="100dp"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
4 changes: 3 additions & 1 deletion app/src/main/res/layout/fragment_editar_tarea.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@
android:id="@+id/btnCancel"
style="@style/ChronoMasterTheme.Button"
android:text="@string/btnCancel"
app:cornerRadius="20dp" />
app:cornerRadius="20dp"
android:layout_marginBottom="100dp"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_ver_listado.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nameUser"
app:layout_constraintVertical_bias="0.344">
app:layout_constraintVertical_bias="0.344"
android:layout_marginBottom="100dp">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerTareas"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<resources>
<string name="appName">Chrono Master</string>
<string name="activityMainLogIn">Log In</string>
<string name="activitySignUpTitle">Sign Up</string>
<string name="usrPlaceholder">Usuario</string>
Expand Down
26 changes: 26 additions & 0 deletions app/src/paid/java/com/equipo22/agenda/AdsFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.equipo22.agenda

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Toast
import androidx.fragment.app.Fragment
import com.google.android.material.button.MaterialButton



class AdsFragment : Fragment() {

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_ads, container, false)

}
}
9 changes: 9 additions & 0 deletions app/src/paid/res/layout/fragment_ads.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="100dp"
tools:context=".tareas.TareaManagementActivity">

</LinearLayout>
4 changes: 4 additions & 0 deletions app/src/paid/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<string name="adsButton">Quitar anuncios</string>
<string name="paidOut">Gracias por su compra</string>
</resources>

0 comments on commit 01f6a4f

Please sign in to comment.