Leo Edge Screen (三星曲面开源)


Screenshot_20190815-173452_LeoTweaks.jpg

本项目是适用于三星手机

下载SDK

下载SDK完成后解压SDK将sdk-v1.0.0.jar slook_v1.4.0.jar 放入你项目的libs文件夹下
在你的项目中引入SDK

在你  项目中的app/build.gradle
dependencies {
    implementation files('libs/sdk-v1.0.0.jar')
    implementation files('libs/slook_v1.4.0.jar')
}

三星官方文档

layout部分
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:importantForAccessibility="2"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:gravity="center"

        android:background="#66494848"
        android:orientation="vertical" >
        <TextView
            android:layout_marginBottom="5dp"
            android:drawableTop="@drawable/ic_apps"
            android:id="@+id/edge_apps"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:fontFamily="sec-roboto-light"
            android:drawablePadding="5dp"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />

        <TextView
            android:id="@+id/edge_wifi"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:clickable="true"
            android:drawableTop="@drawable/ic_wifi"
            android:drawablePadding="5dp"
            android:fontFamily="sec-roboto-light"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:textAppearance="?android:attr/textAppearanceSmall" />
        <TextView
            android:drawablePadding="5dp"
            android:layout_marginBottom="5dp"
            android:drawableTop="@drawable/ic_leo"
            android:id="@+id/edge_leo"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:fontFamily="sec-roboto-light"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />
        <TextView
            android:drawablePadding="5dp"
            android:layout_marginBottom="5dp"
            android:drawableTop="@drawable/ic_clear"
            android:id="@+id/edge_clear"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:fontFamily="sec-roboto-light"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />
        <TextView
            android:drawableTop="@drawable/ic_lock_screen"
            android:id="@+id/edge_lock"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:fontFamily="sec-roboto-light"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />
        <TextView
            android:drawablePadding="5dp"
            android:layout_marginBottom="5dp"
            android:drawableTop="@drawable/ic_donate"
            android:id="@+id/edge_donate"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:fontFamily="sec-roboto-light"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />

        <TextView
            android:drawablePadding="5dp"
            android:layout_marginBottom="5dp"
            android:id="@+id/edge_alipay"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:drawableTop="@drawable/scan_alipay"
            android:fontFamily="sec-roboto-light"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
            android:drawablePadding="5dp"
            android:layout_marginBottom="5dp"
            android:drawableTop="@drawable/scan_weixin"
            android:id="@+id/edge_wechat"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:fontFamily="sec-roboto-light"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />
        <TextView
            android:drawablePadding="5dp"
            android:layout_marginBottom="5dp"
            android:drawableTop="@drawable/ic_fusion"
            android:id="@+id/edge_fusion"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:clickable="true"
            android:gravity="center"
            android:padding="@dimen/default_panel_icon_padding"
            android:fontFamily="sec-roboto-light"
            android:textAppearance="?android:attr/textAppearanceSmall"
            />
    </LinearLayout>
</LinearLayout>


AndroidManifest部分
权限
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY" />
在
application中加入

 <receiver android:name="com.leo.salt.edgescreen.CocktailSaltProvider" >
            <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/edge_single_plus" />
        </receiver>

xml部分
<?xml version="1.0" encoding="utf-8"?>
<cocktail-provider xmlns:android="http://schemas.android.com/apk/res/android"
    previewImage="@drawable/apps_edge_bg"
    label="@string/edge_single_plus_name"
    description="@string/description_edge_single_plus"
    cocktailWidth="550"
    configure="com.leo.salt.activity.EdgeScreenActivity">
</cocktail-provider>

java部分
package com.leo.salt.edgescreen;


public class CocktailSaltProvider extends SlookCocktailProvider {

    @Override
    public void onUpdate(Context context, SlookCocktailManager cocktailBarManager, int[] cocktailIds) {
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout. cocktail_salt_panel);

        setPendingIntent(context, rv);
        for (int i = 0; i < cocktailIds.length; i++) {
            cocktailBarManager.updateCocktail(cocktailIds[i], rv);
        }

    }
    public int mAPPS;
    public int mWIFI;
    public int mLeo;
    public int mClear;
    public int mLock;
    public int mDonate;
    public int mAlipay;
    public int mWeChat;
    public int mFusionLeoKernel;
    private void setPendingIntent(Context context, RemoteViews remoteViews) {
        mAPPS =R.id.edge_apps;
        setPendingIntent(context,mAPPS, new Intent(context, AppsActivity.class),remoteViews);
        mWIFI =R.id.edge_wifi;
        setPendingIntent(context,mWIFI, new Intent(context, WifiPasswordActivity.class), remoteViews);
        mLeo=R.id.edge_leo;
        setPendingIntent(context,mLeo, new Intent(context, MainActivity.class),remoteViews);
     
        Donate(context,remoteViews);
        mClear= R.id.edge_clear;
        setPendingIntent(context, mClear, new Intent(context, CleanActivity.class), remoteViews);
        lock(context,remoteViews);
        toAliPayScan(context,remoteViews);
        WeChatScan(context,remoteViews);
        FusionLeoKernel(context,remoteViews);
 
        updateAppsSetting(remoteViews,mAPPS,"");
        updateAppsSetting(remoteViews,mWIFI,"");
        updateAppsSetting(remoteViews,mLeo,"");
        updateAppsSetting(remoteViews,mClear,"");
        updateAppsSetting(remoteViews,mLock,"");
        updateAppsSetting(remoteViews,mDonate,"");
        updateAppsSetting(remoteViews,mAlipay,"");
        updateAppsSetting(remoteViews,mWeChat,"");
        updateAppsSetting(remoteViews, "FusionLeo Kernel");
    }
   
    
   public void  updateAppsSetting(RemoteViews rv ,String str){

       rv.setTextViewText(apps, str);
   
   }

    public String setLeoText(String STR){

        return getStringIdentifier(getContext(),STR);
    }
    private void lock(Context context,RemoteViews rv){
        mLock=R.id.edge_lock;
  

    }
    private void setPendingIntent(Context context, int rscId, Intent intent, RemoteViews rv) {
        PendingIntent itemClickPendingIntent = PendingIntent.getActivity(context, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent(rscId, itemClickPendingIntent);
    }
    public  void FusionLeoKernel(Context context, RemoteViews rv) {
        mFusionLeoKernel=R.id.edge_fusion;
        
    }
    public  void toAliPayScan(Context context, RemoteViews rv) {
        mAlipay=R.id.edge_alipay;
        
    }
    private void Donate(Context context, RemoteViews rv){
        mDonate=R.id.edge_donate;
        Intent intent = new Intent(context, DonateActivity.class);
        setPendingIntent(context, mDonate, new Intent(intent), rv);
    }
    public void WeChatScan(Context context, RemoteViews rv) {
        mWeChat=R.id.edge_wechat;
        
    }
    private void getLeoBroadcast(Context context,int rscId,  RemoteViews rv,Intent intent){

        PendingIntent pendingIntent1 = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setOnClickPendingIntent( rscId, pendingIntent1);
    }
}
package com.leo.salt.edgescreen;

public class EdgeConfigure extends Activity {

}

代码都贴出来了 至于点击动作可以根据自己的思路来写 方法有很多
当然还有别的方法来实现 更多请参考三星官方文档如有不足之处还请回复指出
同时也可以根据RemoteViews特性写出不同style的曲面插件 这个根据自己的发挥了

声明:本网站采用BY-NC-SA协议进行授权

版权:LeoROM丨FusionLeo内核丨三星S9丨三星S8|版权所有,违者必究|如未注明,均为原创

转载:转载请注明原文链接 - Leo Edge Screen (三星曲面开源)


不忘初心 方得始终