Skip to content

Commit

Permalink
agregar preferencia para mostrar dock labels
Browse files Browse the repository at this point in the history
  • Loading branch information
saulhdev committed Jul 25, 2020
1 parent d2cccfc commit 1efedd4
Show file tree
Hide file tree
Showing 18 changed files with 366 additions and 150 deletions.
6 changes: 3 additions & 3 deletions Omega/res/layout/search_container_hotseat.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!--
Copyright (C) 2016 The Android Open Source Project
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -13,10 +12,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->

<com.saggitt.omega.qsb.HotseatQsbWidget xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/search_container_hotseat"
android:layout_width="match_parent"
android:layout_height="@dimen/qsb_widget_height"
android:layout_gravity="bottom|center"
android:background="@drawable/bg_qsb_click_feedback"
android:contentDescription="@string/label_search" />
android:contentDescription="@string/label_search" />
1 change: 0 additions & 1 deletion Omega/res/layout/search_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
<com.saggitt.omega.search.SearchWidget xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<include layout="@layout/search_container_hotseat" />
</com.saggitt.omega.search.SearchWidget>
3 changes: 3 additions & 0 deletions Omega/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@
<!-- Tag id used for view scrim -->
<item name="view_scrim" type="id" />

<!-- Out of 100, the percent to shrink the workspace during options mode. -->
<integer name="config_workspaceOptionsShrinkPercentage">70</integer>

</resources>
10 changes: 10 additions & 0 deletions Omega/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@

<dimen name="icon_preview_size">48dp</dimen>

<!-- Hotseat -->
<dimen name="v1_dynamic_grid_hotseat_top_padding">4dp</dimen>
<dimen name="v1_dynamic_grid_hotseat_bottom_padding">2dp</dimen>
<dimen name="v1_dynamic_grid_hotseat_size">80dp</dimen>
<dimen name="dynamic_grid_hotseat_size">70dp</dimen>
<dimen name="dynamic_grid_cell_layout_bottom_padding">0dp</dimen>
<dimen name="dynamic_grid_workspace_page_spacing">4dp</dimen>
<dimen name="dynamic_grid_workspace_top_padding">4dp</dimen>

<!-- QSB -->
<dimen name="hotseat_qsb_bottom_margin">5dp</dimen>
<dimen name="hotseat_qsb_scroll_key_shadow_offset">2dp</dimen>
<dimen name="hotseat_qsb_scroll_shadow_blur_radius">1.5dp</dimen>
<dimen name="hotseat_navbar_padding">24dp</dimen>
<dimen name="qsb_margin_top_adjusting">20dp</dimen>
<dimen name="qsb_mic_width">48dp</dimen>
<dimen name="qsb_shadow_margin">6dp</dimen>
Expand Down
3 changes: 3 additions & 0 deletions Omega/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<string name="summary__full_width_widgets">Allow widgets to span over the whole width without padding</string>

<!-- PREFERENCES DOCK -->
<string name="title__dock_hide">Dock Hide</string>
<string name="title__dock_hide_labels">Hide Labels</string>
<string name="title__dock_search_bar">Show Search Bar</string>

<!-- PREFERENCES DRAWER -->
Expand Down Expand Up @@ -87,6 +89,7 @@

<!-- SEARCH -->
<string name="title__search_provider">Search engine</string>
<string name="cat_search_bar">Search Bar</string>
<string name="search_no_results">No Results</string>
<string name="search_breadcrumb_connector" translatable="false">
<xliff:g name="first_item">%1$s</xliff:g> >
Expand Down
10 changes: 8 additions & 2 deletions Omega/res/xml/omega_preferences_dock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.saggitt.omega.preferences.StyledSwitchPreference
android:defaultValue="true"
android:key="pref_key__hide_hotseat"
android:persistent="true"
android:title="@string/title__dock_hide"
app:iconSpaceReserved="false" />

<com.saggitt.omega.preferences.StyledSwitchPreference
android:defaultValue="true"
android:key="pref_dockSearchBar"
android:key="pref_hideDockLabels"
android:persistent="true"
android:title="@string/title__dock_search_bar"
android:title="@string/title__dock_hide_labels"
app:iconSpaceReserved="false" />
</PreferenceScreen>
17 changes: 14 additions & 3 deletions Omega/src/com/saggitt/omega/OmegaPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class OmegaPreferences(val context: Context) : SharedPreferences.OnSharedPrefere
val doNothing = { }
val restart = { restart() }
val reloadApps = { reloadApps() }
val reloadAll = { reloadAll() }
val updateBlur = { updateBlur() }
val recreate = { recreate() }
val omegaConfig = Config(context)
Expand All @@ -67,9 +68,12 @@ class OmegaPreferences(val context: Context) : SharedPreferences.OnSharedPrefere
var hiddenAppSet by StringSetPref("hidden-app-set", Collections.emptySet(), reloadApps)
var hiddenPredictionAppSet by StringSetPref("pref_hidden_prediction_set", Collections.emptySet(), doNothing)
val drawerLabelColor by IntPref("pref_key__drawer_label_color", R.color.qsb_drawer_text_color_normal, reloadApps)
var allAppsGlobalSearch by BooleanPref("pref_allAppsGoogleSearch", false, doNothing)
var allAppsGlobalSearch by BooleanPref("pref_allAppsGoogleSearch", true, doNothing)
val allAppsSearch by BooleanPref("pref_allAppsSearch", true, recreate)

val drawerTextScale by FloatPref("pref_allAppsIconTextScale", 1f, recreate)
val drawerPaddingScale by FloatPref("pref_allAppsPaddingScale", 1.0f, recreate)
private val drawerMultilineLabel by BooleanPref("pref_iconLabelsInTwoLines", false, recreate)
val drawerLabelRows get() = if (drawerMultilineLabel) 2 else 1

/* --DESKTOP-- */
var autoAddInstalled by BooleanPref("pref_add_icon_to_home", true, doNothing)
Expand All @@ -79,10 +83,17 @@ class OmegaPreferences(val context: Context) : SharedPreferences.OnSharedPrefere
}

val allowFullWidthWidgets by BooleanPref("pref_fullWidthWidgets", false, restart)
val desktopTextScale by FloatPref("pref_iconTextScale", 1f, reloadAll)
private val homeMultilineLabel by BooleanPref("pref_homeIconLabelsInTwoLines", false, recreate)
val homeLabelRows get() = if (homeMultilineLabel) 2 else 1

/* --DOCK-- */
var dockSearchBar by BooleanPref("pref_dockSearchBar", false, recreate)
var dockHide by BooleanPref("pref_key__hide_hotseat", false, recreate)
val dockTextScale by FloatPref("pref_dockTextScale", -1f, restart)
private val dockMultilineLabel by BooleanPref("pref_dockIconLabelsInTwoLines", false, recreate)
val dockLabelRows get() = if (dockMultilineLabel) 2 else 1
val hideDockLabels by BooleanPref("pref_hideDockLabels", true, restart)
var dockScale by FloatPref("pref_dockScale", -1f, recreate)

/* --THEME-- */
var launcherTheme by StringIntPref("pref_launcherTheme", 1) { ThemeManager.getInstance(context).updateTheme() }
Expand Down
6 changes: 3 additions & 3 deletions Omega/src/com/saggitt/omega/qsb/AbstractQsbLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ protected final int getHeightWithoutPadding() {
return (getHeight() - getPaddingTop()) - getPaddingBottom();
}

protected final int dD() {
protected final int getIconWidth() {
return mUseTwoBubbles ? mSearchIconWidth : mSearchIconWidth + qsbTextSpacing;
}

Expand All @@ -468,9 +468,9 @@ protected final void setHintText(String str, TextView textView) {
if (dE()) {
i = 8388629;
if (mIsRtl) {
textView.setPadding(dD(), 0, 0, 0);
textView.setPadding(getIconWidth(), 0, 0, 0);
} else {
textView.setPadding(0, 0, dD() + 75, 0);
textView.setPadding(0, 0, getIconWidth() + 75, 0);
}
}
textView.setGravity(i);
Expand Down
11 changes: 6 additions & 5 deletions Omega/src/com/saggitt/omega/qsb/AllAppsQsbLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@

import java.util.Objects;

public class AllAppsQsbLayout extends AbstractQsbLayout implements SearchUiManager, k.o {
public class AllAppsQsbLayout extends AbstractQsbLayout implements SearchUiManager, QsbChangeListener {

private final k Ds;
private final QsbConfiguration Ds;
private final int marginTop;
public float appsVerticalOffset;
boolean mDoNotRemoveFallback;
Expand All @@ -76,9 +76,9 @@ public AllAppsQsbLayout(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mShadowAlpha = 0;
setOnClickListener(this);
this.Ds = k.getInstance(context);
this.Ds = QsbConfiguration.getInstance(context);
this.marginTop = getResources().getDimensionPixelSize(R.dimen.qsb_margin_top_adjusting);
this.appsVerticalOffset = getResources().getDimensionPixelSize(R.dimen.all_apps_search_vertical_offset);
appsVerticalOffset = getResources().getDimensionPixelSize(R.dimen.all_apps_search_vertical_offset);
setClipToPadding(false);
prefs = OmegaPreferences.Companion.getInstanceNoCreate();

Expand All @@ -98,6 +98,7 @@ public void setInsets(Rect rect) {
if (mLauncher.getDeviceProfile().isVerticalBarLayout()) {
mLauncher.getAllAppsController().setScrollRangeDelta(0);
} else {
//TODO: CHECK BOTTOM MARGING
float delta = HotseatQsbWidget.getBottomMargin(mLauncher, false) + appsVerticalOffset;
if (!prefs.getDockHide()) {
delta += mlp.height + mlp.topMargin;
Expand Down Expand Up @@ -173,7 +174,7 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
mAppsView.setRecyclerViewVerticalFadingEdgeEnabled(!mLowPerformanceMode);
}

public final void onChangeListener() {
public final void onChange() {
updateConfiguration();
invalidate();
}
Expand Down
77 changes: 31 additions & 46 deletions Omega/src/com/saggitt/omega/qsb/ConfigBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.ItemInfoWithIcon;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.AllAppsRecyclerView;
Expand All @@ -46,6 +45,7 @@
import com.android.launcher3.icons.BitmapRenderer;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.Themes;
import com.google.protobuf.nano.MessageNano;
import com.saggitt.omega.OmegaLauncher;
import com.saggitt.omega.search.AppSearchProvider;
import com.saggitt.omega.search.nano.SearchProto.AppIndex;
Expand All @@ -55,7 +55,6 @@
import com.saggitt.omega.util.Config;

import java.util.ArrayList;
import java.util.List;


public class ConfigBuilder {
Expand Down Expand Up @@ -112,7 +111,7 @@ private static Columns getViewBounds(final View view) {
return a;
}

private void bW() {
private void updateHotseatSearchDimens() {
if (mNano.appsView != null) {
return;
}
Expand All @@ -134,20 +133,17 @@ private int getBackgroundColor() {
ColorUtils.setAlphaComponent(WallpaperColorInfo.getInstance(mActivity).getMainColor(), 255));
}

private AppIndex bZ(final AppInfo appInfo, final int n) {
if (appInfo == null) {
return null;
}
final AppIndex b = new AppIndex();
b.label = appInfo.title.toString();
b.iconBitmap = "icon_bitmap_" + n;
mBundle.putParcelable(b.iconBitmap, appInfo.iconBitmap);
public final AppIndex updatePredictions(AppInfo appInfo, int n) {
final AppIndex apps = new AppIndex();
apps.label = appInfo.title.toString();
apps.iconBitmap = "icon_bitmap_" + n;
mBundle.putParcelable(apps.iconBitmap, appInfo.iconBitmap);
Uri uri = AppSearchProvider.buildUri(appInfo, mUserManager);
b.searchUri = uri.toString();
b.predictionRank = new Intent("com.saggitt.omega.search.APP_LAUNCH",
apps.searchUri = uri.toString();
apps.predictionRank = new Intent("com.google.android.apps.nexuslauncher.search.APP_LAUNCH",
uri.buildUpon().appendQueryParameter("predictionRank", Integer.toString(n)).build())
.toUri(0);
return b;
return apps;
}

private RemoteViews searchIconTemplate() {
Expand Down Expand Up @@ -194,7 +190,7 @@ private RemoteViews searchQsbTemplate() {
return remoteViews;
}

private void cd() {
private void createSearchTemplate() {
mNano.searchTemplate = "search_box_template";
mBundle.putParcelable(mNano.searchTemplate, searchQsbTemplate());
mNano.gIcon = R.id.g_icon;
Expand Down Expand Up @@ -244,7 +240,7 @@ private void a(Canvas canvas, View view) {
canvas.translate((float) array[0], (float) array[1]);
}

private void ce() {
private void setAllAppsSearchView() {
View view = null;
AllAppsRecyclerView appsView = getAppsView();
GridLayoutManager.SpanSizeLookup spanSizeLookup = ((GridLayoutManager) appsView.getLayoutManager())
Expand Down Expand Up @@ -272,7 +268,7 @@ private void ce() {
}
if (bubbleTextViewArr.length == 0 || bubbleTextViewArr[0] == null) {
Log.e("ConfigBuilder", "No icons rendered in all apps");
cf();
setHotseatSearchView();
return;
}
mBubbleTextView = bubbleTextViewArr[0];
Expand Down Expand Up @@ -311,35 +307,24 @@ private void ce() {
viewBounds3.iconDistance = firstColumn.iconDistance;
mNano.appsView = viewBounds3;
}
bW();
List<ItemInfoWithIcon> predictedApps = mActivity.getAppsView().getFloatingHeaderView().getPredictionRowView().getPredictedApps();
List<AppIndex> bSearches = new ArrayList<>();
final int count = Math.min(predictedApps.size(), allAppsCols);
for (int i = 0; i < count; i++) {
/*AppIndex bSearch = bZ(mActivity.getAppsView().getAppsStore().getApp(predictedApps.get(i).getTargetComponent()), i);
if (bSearch != null) {
bSearches.add(bSearch);
}*/
}
mNano.index = new AppIndex[bSearches.size()];
bSearches.toArray(mNano.index);
updateHotseatSearchDimens();
}

private void cf() {
private void setHotseatSearchView() {
mNano.allAppsCols = mActivity.getDeviceProfile().inv.numColumns;
final int width = mActivity.getHotseat().getWidth();
final int dimensionPixelSize = mActivity.getResources().getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
final Columns en = new Columns();
en.edgeMargin = dimensionPixelSize;
en.iconDistance = width - dimensionPixelSize - dimensionPixelSize;
en.height = mActivity.getDeviceProfile().allAppsCellHeightPx;
mNano.apps = en;
bW();
final AlphabeticalAppsList apps = getAppsView().getApps();
final Columns appCol = new Columns();
appCol.edgeMargin = dimensionPixelSize;
appCol.iconDistance = width - dimensionPixelSize - dimensionPixelSize;
appCol.height = mActivity.getDeviceProfile().allAppsCellHeightPx;
mNano.apps = appCol;
updateHotseatSearchDimens();
AlphabeticalAppsList apps = getAppsView().getApps();
mBubbleTextView = (BubbleTextView) mActivity.getLayoutInflater().inflate(R.layout.all_apps_icon, getAppsView(), false);
final ViewGroup.LayoutParams layoutParams = mBubbleTextView.getLayoutParams();
layoutParams.height = en.height;
layoutParams.width = en.iconDistance / mNano.allAppsCols;
ViewGroup.LayoutParams layoutParams = mBubbleTextView.getLayoutParams();
layoutParams.height = appCol.height;
layoutParams.width = appCol.iconDistance / mNano.allAppsCols;
if (!apps.getApps().isEmpty()) {
mBubbleTextView.applyFromApplicationInfo(apps.getApps().get(0));
}
Expand All @@ -353,9 +338,9 @@ public byte[] build() {
mNano.bgColor = getBackgroundColor();
mNano.isDark = Themes.getAttrBoolean(mActivity, R.attr.isMainColorDark);
if (mIsAllApps) {
ce();
setAllAppsSearchView();
} else {
cf();
setHotseatSearchView();
}
mNano.iconViewTemplate = "icon_view_template";
mBundle.putParcelable(mNano.iconViewTemplate, searchIconTemplate());
Expand All @@ -365,11 +350,11 @@ public byte[] build() {
mNano.bounds = getViewBounds(mQsbLayout);
mNano.isAllApps = mIsAllApps;
if (mIsAllApps) {
cd();
createSearchTemplate();
}
final SearchView d = new SearchView();
d.base = mNano;
return com.google.protobuf.nano.MessageNano.toByteArray(d);
SearchView searchView = new SearchView();
searchView.base = mNano;
return MessageNano.toByteArray(searchView);
}

public Bundle getExtras() {
Expand Down
Loading

0 comments on commit 1efedd4

Please sign in to comment.