0

What are things should be care of to achieve the visability of edge panel ? I Read the docs but still can’t add edge panel in Panels settings

Repo : https://github.com/A7MeDG0L0L/Prayer_time_panel

Build.gradle .. I added in dependencies sdk jar files

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.prayer_time_panel'
compileSdk 33

defaultConfig {
    applicationId "com.prayer_time_panel"
    minSdk 24
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = '1.8'
 }
}

dependencies {

implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
//    implementation 'com.samsung.android:edge-service:1.0.0'
//    implementation "com.samsung.android.sdk.edge:edge-display:1.0.0"
implementation fileTree(include: '*.jar', dir: 'libs')
implementation files('libs/sdk-v1.0.0.jar')
implementation files('libs/slook_v1.4.0.jar')
implementation 'androidx.preference:preference:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

Manifest .. here I added Required recevier and Permission in the docs

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    android:fullBackupContent="@xml/backup_rules"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/Theme.Prayer_time_panel"
    tools:targetApi="31">
    <activity
        android:name=".SettingsActivity"
        android:configChanges="keyboardHidden|screenSize|orientation"
        android:screenOrientation="sensor"
        android:exported="false"
        android:label="@string/title_activity_settings" />
    <activity
        android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <receiver
        android:name=".Cocktail"
        android:label="CocktailMonitorReceiver"
        android:exported="true">
        <intent-filter>
            <action android:name="com.samsung.android.cocktail.v2.action.COCKTAIL_UPDATE" />
        </intent-filter>

        <meta-data
            android:name="com.samsung.android.cocktail.provider"
            android:resource="@xml/cocktail_provider" />
    </receiver>

    <meta-data
        android:name="com.samsung.android.cocktail.mode"
        android:value="cocktail_provider" />

</application>

cocktail_provider.xml .. here cocktail Provider with was required in the docs

<?xml version="1.0" encoding="utf-8"?>
<cocktail-provider xmlns:android="http://schemas.android.com/apk/res/android"
category="feeds"
configure="com.example.edge.EdgeConfigure"
decription="@string/edge_description"
label="@string/edge_name"
permitVisibilityChanged="true"
cocktailWidth="550"
launchOnClick="com.prayer_time_panel.SettingsActivity"
updatePeriodMills="1800000">

</cocktail-provider>

My Cocktail Class .. which inherited SlookCocktailProvider in Samsung SDK

package com.prayer_time_panel

import android.app.PendingIntent
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.widget.RemoteViews
import com.samsung.android.sdk.look.cocktailbar.SlookCocktailManager
import com.samsung.android.sdk.look.cocktailbar.SlookCocktailProvider

class Cocktail : SlookCocktailProvider() {

override fun onUpdate(
    context: Context?,
    cocktailManager: SlookCocktailManager?,
    cocktailIds: IntArray?
) {
    println("onUpdate")
    super.onUpdate(context, cocktailManager, cocktailIds)
    if(context != null)  {
        val cm = cocktailManager ?: SlookCocktailManager.getInstance(context)
        val ids = cocktailIds ?: cm.getCocktailIds(ComponentName(context, Cocktail::class.java))
        println("onUpdate")
        if (ids != null) {
            val rv = RemoteViews(context.packageName, R.layout.cocktail_layout)
            val str = context.resources.getString(R.string.app_name)

            rv.setTextViewText(R.id.remote_list,str)
            setPendingIntent(context, rv)
            for (i in ids.indices) {
                cocktailManager?.updateCocktail(ids[i], rv)
            }
        }
    }
}

private fun setPendingIntent(context: Context, rv: RemoteViews) {
    setPendingIntent(context, R.id.remote_list, Intent(Intent.ACTION_DIAL), rv)
    setPendingIntent(context, R.id.translate, 
Intent("android.media.action.IMAGE_CAPTURE"), rv)
    setPendingIntent(
        context,
        R.id.settings,
        Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")),
        rv
    )
}

private fun setPendingIntent(context: Context, rscId: Int, intent: Intent, rv: 
RemoteViews) {
    val itemClickPendingIntent = PendingIntent.getActivity(
        context, 0, intent,
        PendingIntent.FLAG_UPDATE_CURRENT
    )
    rv.setOnClickPendingIntent(rscId, itemClickPendingIntent)
  }
}

0 Answers0