Merge "Add interface and extend db to support storing slice uris"
This commit is contained in:
@@ -14,7 +14,10 @@
|
||||
package com.android.settings.core;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -22,6 +25,7 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.slices.SettingsSliceProvider;
|
||||
import com.android.settings.slices.SliceData;
|
||||
import com.android.settings.slices.Sliceable;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -156,7 +160,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@AvailabilityStatus} for the Setting. This status is used to determine if the
|
||||
* @return {@link AvailabilityStatus} for the Setting. This status is used to determine if the
|
||||
* Setting should be shown or disabled in Settings. Further, it can be used to produce
|
||||
* appropriate error / warning Slice in the case of unavailability.
|
||||
* </p>
|
||||
@@ -171,6 +175,19 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
|
||||
return mPreferenceKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getSliceUri() {
|
||||
return new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
// Default to non-platform authority. Platform Slices will override authority
|
||||
// accordingly.
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
// Default to action based slices. Intent based slices will override accordingly.
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(getPreferenceKey())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} when the controller can be changed on the device.
|
||||
*
|
||||
|
@@ -22,6 +22,7 @@ import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -54,6 +55,13 @@ public interface Sliceable {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns uri for this slice (if it's a slice).
|
||||
*/
|
||||
default Uri getSliceUri() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the setting update asynchronously.
|
||||
* <p>
|
||||
|
@@ -53,7 +53,7 @@ public class SlicesDatabaseAccessor {
|
||||
};
|
||||
|
||||
// Cursor value for boolean true
|
||||
private final int TRUE = 1;
|
||||
private static final int TRUE = 1;
|
||||
|
||||
private final Context mContext;
|
||||
private final SlicesDatabaseHelper mHelper;
|
||||
@@ -151,7 +151,7 @@ public class SlicesDatabaseAccessor {
|
||||
.toString();
|
||||
}
|
||||
|
||||
private SliceData buildSliceData(Cursor cursor, Uri uri, boolean isIntentOnly) {
|
||||
private static SliceData buildSliceData(Cursor cursor, Uri uri, boolean isIntentOnly) {
|
||||
final String key = cursor.getString(cursor.getColumnIndex(IndexColumns.KEY));
|
||||
final String title = cursor.getString(cursor.getColumnIndex(IndexColumns.TITLE));
|
||||
final String summary = cursor.getString(cursor.getColumnIndex(IndexColumns.SUMMARY));
|
||||
|
@@ -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 = 5;
|
||||
private static final int DATABASE_VERSION = 6;
|
||||
|
||||
public interface Tables {
|
||||
String TABLE_SLICES_INDEX = "slices_index";
|
||||
@@ -98,6 +98,11 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
|
||||
* Customized subtitle if it's a unavailable slice
|
||||
*/
|
||||
String UNAVAILABLE_SLICE_SUBTITLE = "unavailable_slice_subtitle";
|
||||
|
||||
/**
|
||||
* The uri of slice.
|
||||
*/
|
||||
String SLICE_URI = "slice_uri";
|
||||
}
|
||||
|
||||
private static final String CREATE_SLICES_TABLE =
|
||||
@@ -105,6 +110,8 @@ public class SlicesDatabaseHelper extends SQLiteOpenHelper {
|
||||
"(" +
|
||||
IndexColumns.KEY +
|
||||
", " +
|
||||
IndexColumns.SLICE_URI +
|
||||
", " +
|
||||
IndexColumns.TITLE +
|
||||
", " +
|
||||
IndexColumns.SUMMARY +
|
||||
|
@@ -65,6 +65,7 @@ public class SlicesDatabaseHelperTest {
|
||||
|
||||
String[] expectedNames = {
|
||||
IndexColumns.KEY,
|
||||
IndexColumns.SLICE_URI,
|
||||
IndexColumns.TITLE,
|
||||
IndexColumns.SUMMARY,
|
||||
IndexColumns.SCREENTITLE,
|
||||
|
Reference in New Issue
Block a user