Skip to content

Commit

Permalink
- improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
s4kibs4mi committed Sep 25, 2022
1 parent 996fc42 commit 2c160b8
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ class CacheStorage(ctx: Context) : ICacheStorage {
editor.remove(key)
return editor.commit()
}

override fun cleanAll(): Boolean {
return store.edit().clear().commit()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ interface ICacheStorage {
fun save(key: String, value: String): Boolean
fun get(key: String): String
fun delete(key: String): Boolean
fun cleanAll(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class BarcodeScannerActivity : BaseActivity(), PermissionListener {
&& secret.key!!.isNotEmpty() && secret.secret!!.isNotEmpty()
) {
val c = getCacheStorage(applicationContext)
c.cleanAll()

c.save(Constants.storeKeyLabel, secret.key!!)
c.save(Constants.storeSecretLabel, secret.secret!!)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Base64
import android.util.Log
import cn.pedant.SweetAlert.SweetAlertDialog
import com.google.gson.Gson
import com.shopemaa.android.storefront.R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.shopemaa.android.storefront.ui.activities

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.lifecycle.lifecycleScope
Expand All @@ -23,6 +24,7 @@ class StoreActivity : BaseActivity(), StoreView {
private lateinit var storeLogo: ImageView
private lateinit var storeName: TextView
private lateinit var storeBrowseBtn: MaterialButton
private lateinit var storeRescanBtn: Button

private lateinit var alertDialog: SweetAlertDialog

Expand All @@ -40,6 +42,10 @@ class StoreActivity : BaseActivity(), StoreView {
startActivity(Intent(applicationContext, HomeActivity::class.java))
finish()
}
storeRescanBtn = findViewById(R.id.store_rescan_btn)
storeRescanBtn.setOnClickListener {
startActivity(Intent(this, BarcodeScannerActivity::class.java))
}

alertDialog = createLoader(this, "Loading...")

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/drawable/alternative_btn.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="40dp"
android:shape="rectangle">

<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />

<stroke
android:width="3dp"
android:color="@color/secondary" />

<gradient
android:angle="-90"
android:endColor="@color/secondary"
android:startColor="@color/secondary" />
</shape>
17 changes: 15 additions & 2 deletions app/src/main/res/layout/activity_store.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,30 @@
android:layout_below="@id/store_welcome"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Welcome"
android:text=""
android:textSize="32sp"
android:textStyle="bold" />

<com.google.android.material.button.MaterialButton
android:id="@+id/store_browse_btn"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_below="@+id/store_name"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
android:layout_marginRight="20dp"
android:background="@drawable/primary_btn"
android:text="Browse" />

<Button
android:id="@+id/store_rescan_btn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_marginLeft="60dp"
android:layout_marginTop="30dp"
android:layout_marginRight="60dp"
android:background="@drawable/alternative_btn"
android:text="Rescan QR" />

</RelativeLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_order_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/customer_email"
android:background="@drawable/primary_btn"
android:text="Order Details"
android:textAllCaps="false"
android:textSize="18sp" />
Expand Down
25 changes: 1 addition & 24 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="@+id/nav_graph"
app:startDestination="@id/FirstFragment">
android:id="@+id/nav_graph">

<fragment
android:id="@+id/FirstFragment"
android:name="com.shopemaa.android.storefront.ui.activities.FirstFragment"
android:label="@string/first_fragment_label"
tools:layout="@layout/fragment_first">

<action
android:id="@+id/action_FirstFragment_to_SecondFragment"
app:destination="@id/SecondFragment" />
</fragment>
<fragment
android:id="@+id/SecondFragment"
android:name="com.shopemaa.android.storefront.ui.activities.SecondFragment"
android:label="@string/second_fragment_label"
tools:layout="@layout/fragment_second">

<action
android:id="@+id/action_SecondFragment_to_FirstFragment"
app:destination="@id/FirstFragment" />
</fragment>
</navigation>

0 comments on commit 2c160b8

Please sign in to comment.