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

Commit c19f4f41 authored by Yi-Ling Chuang's avatar Yi-Ling Chuang Committed by Android (Google) Code Review
Browse files

Merge "Add a new column for slices_index table."

parents 5035742f c7cd6c46
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ public class SliceData {

    private final String mUnavailableSliceSubtitle;

    private final boolean mIsPublicSlice;

    public String getKey() {
        return mKey;
    }
@@ -117,6 +119,10 @@ public class SliceData {
        return mUnavailableSliceSubtitle;
    }

    public boolean isPublicSlice() {
        return mIsPublicSlice;
    }

    private SliceData(Builder builder) {
        mKey = builder.mKey;
        mTitle = builder.mTitle;
@@ -129,6 +135,7 @@ public class SliceData {
        mPreferenceController = builder.mPrefControllerClassName;
        mSliceType = builder.mSliceType;
        mUnavailableSliceSubtitle = builder.mUnavailableSliceSubtitle;
        mIsPublicSlice = builder.mIsPublicSlice;
    }

    @Override
@@ -168,6 +175,8 @@ public class SliceData {

        private String mUnavailableSliceSubtitle;

        private boolean mIsPublicSlice;

        public Builder setKey(String key) {
            mKey = key;
            return this;
@@ -224,6 +233,11 @@ public class SliceData {
            return this;
        }

        public Builder setIsPublicSlice(boolean isPublicSlice) {
            mIsPublicSlice = isPublicSlice;
            return this;
        }

        public SliceData build() {
            if (TextUtils.isEmpty(mKey)) {
                throw new InvalidSliceDataException("Key cannot be empty");
+2 −0
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ class SliceDataConverter {
                final int sliceType = controller.getSliceType();
                final String unavailableSliceSubtitle = bundle.getString(
                        METADATA_UNAVAILABLE_SLICE_SUBTITLE);
                final boolean isPublicSlice = controller.isPublicSlice();

                final SliceData xmlSlice = new SliceData.Builder()
                        .setKey(key)
@@ -224,6 +225,7 @@ class SliceDataConverter {
                        .setFragmentName(fragmentName)
                        .setSliceType(sliceType)
                        .setUnavailableSliceSubtitle(unavailableSliceSubtitle)
                        .setIsPublicSlice(isPublicSlice)
                        .build();

                xmlSliceData.add(xmlSlice);
+12 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "slices_index.db";
    private static final String SHARED_PREFS_TAG = "slices_shared_prefs";

    private static final int DATABASE_VERSION = 7;
    private static final int DATABASE_VERSION = 8;

    public interface Tables {
        String TABLE_SLICES_INDEX = "slices_index";
@@ -98,6 +98,11 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
         * The uri of slice.
         */
        String SLICE_URI = "slice_uri";

        /**
         * Whether the slice should be exposed publicly.
         */
        String PUBLIC_SLICE = "public_slice";
    }

    private static final String CREATE_SLICES_TABLE =
@@ -124,6 +129,12 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
                    IndexColumns.SLICE_TYPE +
                    ", " +
                    IndexColumns.UNAVAILABLE_SLICE_SUBTITLE +
                    ", "
                    +
                    IndexColumns.PUBLIC_SLICE
                    +
                    " INTEGER DEFAULT 0 "
                    +
                    ");";

    private final Context mContext;
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ class SlicesIndexer implements Runnable {
            values.put(IndexColumns.SLICE_TYPE, dataRow.getSliceType());
            values.put(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
                    dataRow.getUnavailableSliceSubtitle());
            values.put(IndexColumns.PUBLIC_SLICE, dataRow.isPublicSlice());

            database.replaceOrThrow(Tables.TABLE_SLICES_INDEX, null /* nullColumnHack */,
                    values);
+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,11 @@ public class FakePreferenceController extends BasePreferenceController {
        return true;
    }

    @Override
    public boolean isPublicSlice() {
        return true;
    }

    @Override
    public boolean useDynamicSliceSummary() {
        return true;
Loading