Skip to content

Commit 1e42e70

Browse files
updated code
1 parent 8e6b98c commit 1e42e70

8 files changed

Lines changed: 93 additions & 184 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
.externalNativeBuild
1414
.cxx
1515
local.properties
16+
/app/release/app-release.aab

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ plugins {
1111
android {
1212
buildToolsVersion "30.0.3"
1313
namespace = "com.kharagedition.tibetandictionary"
14-
compileSdk 35
14+
compileSdk 36
1515

1616
defaultConfig {
1717
applicationId "com.kharagedition.tibetandictionary"
1818
minSdkVersion 21
19-
targetSdkVersion 35
20-
versionCode 14
21-
versionName "2.0.5"
19+
targetSdkVersion 36
20+
versionCode 20
21+
versionName "2.1.0"
2222

2323
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2424
multiDexEnabled true
@@ -109,6 +109,4 @@ dependencies {
109109
//google ads
110110
implementation 'com.google.android.gms:play-services-ads:23.4.0'
111111

112-
//BILLING IN APP PURCHASE
113-
implementation 'com.android.billingclient:billing:7.1.0'
114112
}

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
<uses-permission android:name="android.permission.INTERNET" />
77
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
8-
<uses-permission android:name="com.android.vending.BILLING" />
98
<uses-permission android:name="android.permission.CAMERA" />
109
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
1110

app/src/main/java/com/kharagedition/tibetandictionary/ui/SettingActivity.kt

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,22 @@ import android.widget.ImageView
88
import android.widget.Toast
99
import androidx.appcompat.app.AlertDialog
1010
import androidx.appcompat.app.AppCompatActivity
11-
import com.android.billingclient.api.*
1211
import com.google.android.material.button.MaterialButton
1312
import com.google.android.material.textfield.TextInputLayout
1413
import com.google.firebase.firestore.FirebaseFirestore
1514
import com.kharagedition.tibetandictionary.R
16-
import com.kharagedition.tibetandictionary.util.Constant
1715

1816

19-
class SettingActivity : AppCompatActivity(),PurchasesUpdatedListener {
17+
class SettingActivity : AppCompatActivity() {
2018
lateinit var materialToolbar: ImageView
2119
lateinit var storeButton: MaterialButton
2220
lateinit var feedbackButton: MaterialButton
23-
private lateinit var billingClient: BillingClient
24-
private val skuList = listOf("remove_ads_dictionary")
25-
override fun onCreate(savedInstanceState: Bundle?) {
21+
override fun onCreate(savedInstanceState: Bundle?) {
2622
super.onCreate(savedInstanceState)
2723
setContentView(R.layout.activity_setting)
2824
materialToolbar = findViewById(R.id.setting_backbtn)
2925
storeButton = findViewById(R.id.store_btn)
3026
feedbackButton = findViewById(R.id.feedback_btn)
31-
setupBillingClient()
3227
if (savedInstanceState == null) {
3328
supportFragmentManager
3429
.beginTransaction()
@@ -88,98 +83,4 @@ class SettingActivity : AppCompatActivity(),PurchasesUpdatedListener {
8883

8984
}
9085

91-
private fun setupBillingClient() {
92-
billingClient = BillingClient.newBuilder(this)
93-
.enablePendingPurchases()
94-
.setListener(this)
95-
.build()
96-
billingClient.startConnection(object : BillingClientStateListener {
97-
override fun onBillingSetupFinished(billingResult: BillingResult) {
98-
Log.i("TAG", "onBillingSetupFinished: ")
99-
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
100-
loadAllSKUs()
101-
// The BillingClient is setup successfully
102-
}
103-
}
104-
105-
override fun onBillingServiceDisconnected() {
106-
// Try to restart the connection on the next request to
107-
// Google Play by calling the startConnection() method.
108-
Log.e("TAG", "onBillingServiceDisconnected: ")
109-
110-
}
111-
})
112-
113-
}
114-
115-
private fun loadAllSKUs() = if (billingClient.isReady) {
116-
val params = SkuDetailsParams
117-
.newBuilder()
118-
.setSkusList(skuList)
119-
.setType(BillingClient.SkuType.INAPP)
120-
.build()
121-
billingClient.querySkuDetailsAsync(params) { billingResult, skuDetailsList ->
122-
// Process the result.
123-
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK && (skuDetailsList != null && skuDetailsList.isNotEmpty())) {
124-
for (skuDetails in skuDetailsList) {
125-
if (skuDetails.sku == "remove_ads_dictionary") {
126-
storeButton.setOnClickListener{
127-
Log.e("TAG", "loadAllSKUs:LOGGGG ")
128-
val billingFlowParams = BillingFlowParams
129-
.newBuilder()
130-
.setSkuDetails(skuDetails)
131-
.build()
132-
billingClient.launchBillingFlow(this, billingFlowParams)
133-
}
134-
135-
}
136-
}
137-
}
138-
}
139-
140-
} else {
141-
println("Billing Client not ready")
142-
}
143-
144-
override fun onPurchasesUpdated(
145-
billingResult: BillingResult,
146-
purchases: MutableList<Purchase>?
147-
) {
148-
Log.e("TAG", "loadAllSKUs:LOGGGG "+billingResult.responseCode)
149-
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK && purchases != null) {
150-
for (purchase in purchases) {
151-
acknowledgePurchase(purchase.purchaseToken)
152-
}
153-
} else if (billingResult.responseCode == BillingClient.BillingResponseCode.USER_CANCELED) {
154-
Log.e("TAG", "onPurchasesUpdated: CANCELLED")
155-
} else if(billingResult.responseCode == BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED){
156-
Log.e("TAG", "onPurchasesUpdated: ITEM_ALREADY_OWNED")
157-
val prefs = getSharedPreferences(
158-
"com.kharagedition.dictionary", Context.MODE_PRIVATE).edit()
159-
prefs.putBoolean(Constant.PURCHASED,true)
160-
prefs.apply();
161-
}else if(billingResult.responseCode == BillingClient.BillingResponseCode.ITEM_UNAVAILABLE){
162-
Toast.makeText(this, "ITEM NOT AVAILABLE", Toast.LENGTH_SHORT).show()
163-
}else{
164-
Log.e("TAG", "onPurchasesUpdated: ELSE")
165-
}
166-
}
167-
168-
private fun acknowledgePurchase(purchaseToken: String) {
169-
val params = AcknowledgePurchaseParams.newBuilder()
170-
.setPurchaseToken(purchaseToken)
171-
.build()
172-
billingClient.acknowledgePurchase(params) { billingResult ->
173-
val responseCode = billingResult.responseCode
174-
val debugMessage = billingResult.debugMessage
175-
Toast.makeText(this, "TAG$responseCode", Toast.LENGTH_SHORT).show()
176-
//if(responseCode==0)
177-
val prefs = getSharedPreferences(
178-
"com.kharagedition.dictionary", Context.MODE_PRIVATE).edit()
179-
prefs.putBoolean(Constant.PURCHASED,true)
180-
prefs.apply();
181-
}
182-
183-
184-
}
18586
}

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6-
android:background="@color/yellow_200">
6+
android:background="@color/brown_700"
7+
android:fitsSystemWindows="true">
78

89

9-
<fragment
10+
<androidx.fragment.app.FragmentContainerView
1011
android:id="@+id/nav_host_fragment"
1112
android:name="androidx.navigation.fragment.NavHostFragment"
1213
android:layout_width="match_parent"

app/src/main/res/layout/activity_setting.xml

Lines changed: 82 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,84 +4,93 @@
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
66
xmlns:app="http://schemas.android.com/apk/res-auto"
7-
android:background="@color/yellow_200"
7+
android:background="@color/brown_700"
8+
9+
android:fitsSystemWindows="true"
810
android:orientation="vertical">
911
<LinearLayout
10-
android:elevation="5dp"
11-
android:gravity="center_vertical"
12-
android:id="@+id/setting_toolbar"
1312
android:layout_width="match_parent"
14-
android:layout_height="60dp"
15-
android:background="@drawable/ic_wave__top_toolbar"
16-
android:orientation="horizontal"
17-
app:layout_constraintEnd_toEndOf="parent"
18-
app:layout_constraintLeft_toLeftOf="parent"
19-
app:layout_constraintStart_toStartOf="parent"
20-
app:layout_constraintTop_toTopOf="parent" >
21-
<ImageView
22-
android:id="@+id/setting_backbtn"
23-
android:layout_marginStart="15dp"
24-
android:layout_width="wrap_content"
13+
android:layout_height="match_parent"
14+
android:orientation="vertical"
15+
android:background="@color/yellow_200">
16+
<LinearLayout
17+
android:elevation="5dp"
18+
android:gravity="center_vertical"
19+
android:id="@+id/setting_toolbar"
20+
android:layout_width="match_parent"
21+
android:layout_height="60dp"
22+
android:background="@drawable/ic_wave__top_toolbar"
23+
android:orientation="horizontal"
24+
app:layout_constraintEnd_toEndOf="parent"
25+
app:layout_constraintLeft_toLeftOf="parent"
26+
app:layout_constraintStart_toStartOf="parent"
27+
app:layout_constraintTop_toTopOf="parent" >
28+
<ImageView
29+
android:id="@+id/setting_backbtn"
30+
android:layout_marginStart="15dp"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
app:srcCompat="@drawable/ic_baseline_arrow_back_ios_24"
34+
android:layout_marginLeft="15dp" />
35+
<com.google.android.material.textview.MaterialTextView
36+
android:layout_marginStart="5dp"
37+
android:textColor="@color/white"
38+
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
39+
android:layout_width="wrap_content"
40+
android:layout_height="wrap_content"
41+
android:text="@string/settings"
42+
android:layout_marginLeft="10dp" />
43+
</LinearLayout>
44+
<LinearLayout
45+
android:paddingTop="10dp"
46+
android:layout_width="match_parent"
2547
android:layout_height="wrap_content"
26-
app:srcCompat="@drawable/ic_baseline_arrow_back_ios_24"
27-
android:layout_marginLeft="15dp" />
28-
<com.google.android.material.textview.MaterialTextView
29-
android:layout_marginStart="5dp"
30-
android:textColor="@color/white"
31-
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
32-
android:layout_width="wrap_content"
48+
android:paddingStart="10dp"
49+
android:paddingLeft="10dp"
50+
android:paddingEnd="10dp">
51+
<com.google.android.material.textview.MaterialTextView
52+
android:textStyle="bold"
53+
android:id="@android:id/title"
54+
android:textColor="@color/brown_700"
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:textSize="18sp"
58+
android:text="Support/Contribution" />
59+
</LinearLayout>
60+
<LinearLayout
61+
android:visibility="gone"
62+
android:layout_width="match_parent"
3363
android:layout_height="wrap_content"
34-
android:text="@string/settings"
35-
android:layout_marginLeft="10dp" />
36-
</LinearLayout>
37-
<LinearLayout
38-
android:paddingTop="10dp"
39-
android:layout_width="match_parent"
40-
android:layout_height="wrap_content"
41-
android:paddingStart="10dp"
42-
android:paddingLeft="10dp"
43-
android:paddingEnd="10dp">
44-
<com.google.android.material.textview.MaterialTextView
45-
android:textStyle="bold"
46-
android:id="@android:id/title"
47-
android:textColor="@color/brown_700"
48-
android:layout_width="wrap_content"
49-
android:layout_height="wrap_content"
50-
android:textSize="18sp"
51-
android:text="Support/Contribution" />
52-
</LinearLayout>
53-
<LinearLayout
54-
android:layout_width="match_parent"
55-
android:layout_height="wrap_content"
56-
android:paddingStart="10dp"
57-
android:paddingLeft="10dp"
58-
android:paddingEnd="10dp">
59-
<com.google.android.material.button.MaterialButton
60-
android:layout_marginTop="10dp"
61-
android:id="@+id/store_btn"
62-
style="?attr/borderlessButtonStyle"
63-
android:layout_width="wrap_content"
64-
android:layout_height="wrap_content"
65-
android:text="@string/support_developer"
66-
app:icon="@drawable/ic_baseline_local_grocery_store_24" />
67-
</LinearLayout>
68-
<LinearLayout
69-
android:layout_width="match_parent"
70-
android:layout_height="wrap_content"
71-
android:paddingStart="10dp"
72-
android:paddingLeft="10dp"
73-
android:paddingEnd="10dp">
74-
<com.google.android.material.button.MaterialButton
75-
android:layout_marginTop="10dp"
76-
android:id="@+id/feedback_btn"
77-
style="?attr/borderlessButtonStyle"
78-
android:layout_width="wrap_content"
64+
android:paddingStart="10dp"
65+
android:paddingLeft="10dp"
66+
android:paddingEnd="10dp">
67+
<com.google.android.material.button.MaterialButton
68+
android:layout_marginTop="10dp"
69+
android:id="@+id/store_btn"
70+
style="?attr/borderlessButtonStyle"
71+
android:layout_width="wrap_content"
72+
android:layout_height="wrap_content"
73+
android:text="@string/support_developer"
74+
app:icon="@drawable/ic_baseline_local_grocery_store_24" />
75+
</LinearLayout>
76+
<LinearLayout
77+
android:layout_width="match_parent"
7978
android:layout_height="wrap_content"
80-
android:text="@string/send_feature_request"
81-
app:icon="@drawable/ic_baseline_message_24" />
79+
android:paddingStart="10dp"
80+
android:paddingLeft="10dp"
81+
android:paddingEnd="10dp">
82+
<com.google.android.material.button.MaterialButton
83+
android:layout_marginTop="10dp"
84+
android:id="@+id/feedback_btn"
85+
style="?attr/borderlessButtonStyle"
86+
android:layout_width="wrap_content"
87+
android:layout_height="wrap_content"
88+
android:text="@string/send_feature_request"
89+
app:icon="@drawable/ic_baseline_message_24" />
90+
</LinearLayout>
91+
<FrameLayout
92+
android:id="@+id/settings_container"
93+
android:layout_width="match_parent"
94+
android:layout_height="match_parent"/>
8295
</LinearLayout>
83-
<FrameLayout
84-
android:id="@+id/settings_container"
85-
android:layout_width="match_parent"
86-
android:layout_height="match_parent"/>
8796
</LinearLayout>

app/src/main/res/layout/fragment_list.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
android:text="No data found"
4444
android:textSize="20sp"
4545
android:id="@+id/empty_msg"
46+
android:textColor="@color/white"
4647
android:layout_width="wrap_content"
4748
android:layout_height="wrap_content"
4849
ads:layout_constraintTop_toTopOf="parent"

0 commit comments

Comments
 (0)