Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ca32f7a authored by Amit Kumar's avatar Amit Kumar 💻 Committed by Arnau Vàzquez
Browse files

Following changes:

Remove Launcher intent-filter
Use content resolver to fetch app icon and name
parent f87afcc6
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@
        <activity android:name=".ui.home.HomeActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
@@ -38,8 +36,9 @@
            android:exported="true">
            <intent-filter>
                <action android:name="foundation.e.blisslauncher.VIEW_PWA" />

                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>
        </activity>
    </application>
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ data class Pwa(

    @ColumnInfo(name = PwaConstants.TITLE)
    val title: String,

    @ColumnInfo(name = PwaConstants.ICON, typeAffinity = ColumnInfo.BLOB)
    val iconBlob: ByteArray
) {
+4 −2
Original line number Diff line number Diff line
package foundation.e.pwaplayer.provider

import android.content.*
import android.content.ContentProvider
import android.content.ContentUris
import android.content.ContentValues
import android.content.UriMatcher
import android.database.Cursor
import android.net.Uri
import android.util.Log
import androidx.core.content.contentValuesOf
import foundation.e.pwaplayer.database.PwaDatabase
import foundation.e.pwaplayer.database.mapToPwa
import foundation.e.pwaplayer.provider.PwaConstants.Companion.TABLE_NAME
+0 −1
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ class HomeActivity : AppCompatActivity() {
        val cursor = contentResolver.query(CONTENT_URI, null, null, null, null)
        val data = ArrayList<Pwa>()
        if (cursor != null) {
            Log.d(TAG, "loadData: ${cursor.count} ${cursor.columnCount}")
            if (cursor.moveToFirst()) {
                do {
                    val pwa = cursor.mapToPwa()
+2 −10
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import androidx.recyclerview.widget.RecyclerView
import foundation.e.pwaplayer.R
import foundation.e.pwaplayer.database.Pwa
import foundation.e.pwaplayer.ui.player.PwaActivity
import foundation.e.pwaplayer.util.toBitmap

class HomeRecyclerAdapter(
    private val context: Context,
@@ -32,7 +33,7 @@ class HomeRecyclerAdapter(
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT or Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS)
                intent.action = "foundation.e.blisslauncher.VIEW_PWA"
                intent.data = Uri.parse(items[adapterPosition].url)
                intent.putExtra("PWA_NAME", items[adapterPosition].title)
                intent.putExtra(PwaActivity.KEY_PWA_ID, items[adapterPosition].id)
                context.startActivity(intent)
            }
        }
@@ -40,9 +41,6 @@ class HomeRecyclerAdapter(

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PwaViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_pwa, parent, false)
        view.setOnClickListener {

        }
        return PwaViewHolder(view)
    }

@@ -61,9 +59,3 @@ class HomeRecyclerAdapter(
        notifyDataSetChanged()
    }
}

private fun ByteArray.toBitmap(): Bitmap? {
    return BitmapFactory.decodeByteArray(
        this, 0, this.size
    )
}
Loading