OmniLib: Introduce OmniRom SDK

 * omnilib-res app will be installed to system/frameworks for the futur internal ressources add-on
 * OmniLib java_library will be installed to system/frameworks for the futur internal java/aidl add-on
 * The OmniPreference android_library need to be moved outside system/frameworks  because of some nested dependency breakage

Change-Id: I2b9a7bc7f4aa72052ae6600933eb114d2a481b35

omnilib-res: Add allow-reserved-package-id

Thx to the LineageOS team

https://github.com/LineageOS/android_lineage-sdk/blob/lineage-20.0/Android.bp#L44-L49

Change-Id: I07ba56685981a8735bdef5ea75528ec82dd68318
diff --git a/omnipreference/java/omnirom/preference/ScrollAppsViewPreference.java b/omnipreference/java/omnirom/preference/ScrollAppsViewPreference.java
new file mode 100644
index 0000000..bf84431
--- /dev/null
+++ b/omnipreference/java/omnirom/preference/ScrollAppsViewPreference.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2017 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package omnirom.preference;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+
+import omnirom.preference.R;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class ScrollAppsViewPreference extends Preference {
+    private static final String TAG = "ScrollAppsPreference";
+
+    private Context mContext;
+    private List<String> mValues = new ArrayList<String>();
+    private PackageManager mPm;
+    private LayoutInflater mInflater;
+
+    public ScrollAppsViewPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+        initPreference(context);
+    }
+
+    public ScrollAppsViewPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        initPreference(context);
+    }
+
+    public ScrollAppsViewPreference(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        initPreference(context);
+    }
+
+    public void setValues(Collection<String> values) {
+        mValues.clear();
+        mValues.addAll(values);
+    }
+
+    @Override
+    public void onBindViewHolder(PreferenceViewHolder holder) {
+        super.onBindViewHolder(holder);
+        LinearLayout linearLayout = (LinearLayout) holder.findViewById(R.id.selected_apps);
+        if (linearLayout.getChildCount() > 0) linearLayout.removeAllViews();
+
+        for (String value : mValues) {
+            try {
+                View v = mInflater.inflate(R.layout.app_grid_item, null);
+                ComponentName componentName = ComponentName.unflattenFromString(value);
+                Drawable icon = mPm.getActivityIcon(componentName);
+                ((ImageView) v.findViewById(R.id.appIcon)).setImageDrawable(icon);
+                v.setPadding(10, 5, 10, 5);
+                linearLayout.addView(v);
+            } catch (PackageManager.NameNotFoundException e) {
+                Log.e(TAG, "Set app icon", e);
+            }
+        }
+    }
+
+    private void initPreference(Context context) {
+        mContext = context;
+        setLayoutResource(R.layout.preference_selected_apps_view);
+        mPm = context.getPackageManager();
+        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+    }
+}