Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nmc/2035 Navigationview Theming #80

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 54 additions & 180 deletions app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions app/src/main/java/com/owncloud/android/utils/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
*/
package com.owncloud.android.utils;


import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;

import java.util.Locale;
import android.graphics.Typeface;
import android.text.style.StyleSpan;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -55,6 +62,15 @@ String searchAndColor(@Nullable String text, @Nullable String searchText,
}
}

public static Spannable getColorSpan(@NonNull String title, @ColorInt int color) {
Spannable text = new SpannableString(title);
text.setSpan(new ForegroundColorSpan(color),
0,
text.length(),
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return text;
}

public static
@NonNull
String removePrefix(@NonNull String s, @NonNull String prefix) {
Expand All @@ -63,4 +79,19 @@ String removePrefix(@NonNull String s, @NonNull String prefix) {
}
return s;
}

/**
* make the passed text bold
*
* @param fullText actual text
* @param textToBold to be bold
* @return
*/
public static Spannable makeTextBold(String fullText, String textToBold) {
Spannable spannable = new SpannableString(fullText);
int indexStart = fullText.indexOf(textToBold);
int indexEnd = indexStart + textToBold.length();
spannable.setSpan(new StyleSpan(Typeface.BOLD), indexStart, indexEnd, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannable;
}
}
31 changes: 31 additions & 0 deletions app/src/main/res/drawable/ic_magentacloud_product_logo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="40dp"
android:height="40dp"
android:viewportWidth="40"
android:viewportHeight="40">
<group>
<clip-path
android:pathData="M0,0h40v40h-40z"/>
<path
android:pathData="M2.133,0H37.867A2.133,2.133 0,0 1,40 2.133V37.867A2.133,2.133 0,0 1,37.867 40H2.133A2.133,2.133 0,0 1,0 37.867V2.133A2.133,2.133 0,0 1,2.133 0Z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="20"
android:startY="0"
android:endX="20"
android:endY="40"
android:type="linear">
<item android:offset="0" android:color="#FFFE319A"/>
<item android:offset="1" android:color="#FFE20074"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M17.63,30.545a9.886,9.886 0,0 1,-6.811 -2.706,5.4 5.4,0 0,1 -1.188,0.132A5.364,5.364 0,0 1,8.467 17.367a5.328,5.328 0,0 1,6.83 -4.8A8.963,8.963 0,0 1,18.367 10.021a8.877,8.877 0,0 1,1.92 -0.706,8.934 8.934,0 0,1 9.855,4.259 8.843,8.843 0,0 1,1.048 2.95,5.688 5.688,0 0,1 1.8,0.72 5.733,5.733 0,0 1,-3 10.623,5.836 5.836,0 0,1 -0.608,-0.032 5.329,5.329 0,0 1,-6.3 1.224L23.082,22.35h4.423L20.786,15.461 14.015,22.35L18.477,22.35v8.16C18.196,30.533 17.911,30.545 17.63,30.545Z"
android:fillColor="#fff"/>
<path
android:pathData="M27.519,23.889L23.096,23.889L23.096,22.349h2.918l1.505,1.54ZM18.476,23.889L13.976,23.889L15.499,22.349L18.476,22.349L18.476,23.889Z"
android:fillColor="#f9cce3"/>
</group>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/menu_background_color_state.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/nav_selected_bg_color" android:state_checked="true" />
</selector>
41 changes: 32 additions & 9 deletions app/src/main/res/layout/drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,66 @@

<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
style="@style/Widget.Custom.NavigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_weight="1"
android:background="@color/appbar"
android:background="@color/nav_bg_color"
android:fitsSystemWindows="true"
android:theme="@style/NavigationView_ItemTextAppearance"
app:headerLayout="@layout/drawer_header"
app:itemTextColor="@color/drawer_text_color"
app:menu="@menu/partial_drawer_entries">

<LinearLayout
android:id="@+id/drawer_quota"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/nav_bg_color"
android:clickable="false"
android:orientation="vertical"
android:background="@color/appbar"
android:paddingLeft="@dimen/drawer_content_horizontal_padding"
android:paddingTop="@dimen/standard_half_padding"
android:paddingRight="@dimen/drawer_content_horizontal_padding"
android:paddingBottom="@dimen/standard_padding"
android:visibility="gone"
tools:visibility="visible">

<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/nav_divider_color" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/drawer_quota_usage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/standard_half_padding"
android:gravity="center_vertical"
android:paddingLeft="@dimen/standard_padding"
android:paddingTop="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
android:textColor="@color/drawer_quota_txt_color"
android:textSize="@dimen/txt_size_18sp"
app:drawableStartCompat="@drawable/ic_magentacloud_product_logo"
tools:text="1.2 of 5 GB" />

<TextView
android:id="@+id/drawer_quota_link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/alternate_half_padding" />
android:drawablePadding="@dimen/alternate_half_padding"
android:visibility="gone" />

<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/drawer_quota_ProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/standard_margin"
android:layout_marginTop="@dimen/standard_margin"
android:layout_marginRight="@dimen/standard_margin"
android:indeterminate="false"
android:indeterminateOnly="false"
android:text="@string/drawer_quota"
app:trackColor="@color/progress_bar_background"
app:trackCornerRadius="5dp"
app:trackThickness="5dp"
tools:progress="50" />
Expand All @@ -60,9 +81,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/alternate_half_padding"
android:fontFamily="sans-serif-medium"
android:paddingLeft="@dimen/standard_padding"
android:paddingRight="@dimen/standard_padding"
android:text="@string/drawer_quota"
android:textColor="@color/drawer_text_color" />
android:textColor="@color/drawer_quota_txt_color"
android:textSize="@dimen/txt_size_14sp" />

</LinearLayout>

Expand Down
30 changes: 18 additions & 12 deletions app/src/main/res/menu/partial_drawer_entries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@

<item
android:id="@+id/nav_personal_files"
android:visible="false"
android:icon="@drawable/ic_user"
android:orderInCategory="0"
android:title="@string/drawer_item_personal_files" />
<item
android:id="@+id/nav_activity"
android:visible="false"
android:icon="@drawable/ic_activity"
android:title="@string/drawer_item_activities" />
<item
Expand All @@ -52,6 +54,7 @@
android:id="@+id/nav_groupfolders"
android:orderInCategory="0"
android:icon="@drawable/ic_group"
android:visible="false"
android:title="@string/drawer_item_groupfolders" />
<item
android:id="@+id/nav_on_device"
Expand All @@ -62,8 +65,8 @@
android:id="@+id/nav_recently_modified"
android:icon="@drawable/nav_recently"
android:orderInCategory="0"
android:title="@string/drawer_item_recently_modified"
android:visible="true"/>
android:title="@string/drawer_item_recent_files"
android:visible="false"/>
<item
android:orderInCategory="0"
android:id="@+id/nav_notifications"
Expand All @@ -80,12 +83,25 @@
android:id="@+id/nav_uploads"
android:icon="@drawable/uploads"
android:orderInCategory="2"
android:visible="false"
android:title="@string/drawer_item_uploads_list"/>
<item
android:id="@+id/nav_trashbin"
android:icon="@drawable/nav_trashbin"
android:orderInCategory="2"
android:title="@string/drawer_item_trashbin"/>

<item
android:id="@+id/nav_settings"
android:icon="@drawable/nav_settings"
android:orderInCategory="4"
android:title="@string/actionbar_settings"/>

<item
android:id="@+id/nav_logout"
android:icon="@drawable/nav_logout"
android:orderInCategory="4"
android:title="@string/drawer_logout"/>
</group>

<!--
Expand All @@ -102,21 +118,11 @@
<group
android:id="@+id/drawer_menu_bottom"
android:checkableBehavior="single">
<item
android:id="@+id/nav_settings"
android:icon="@drawable/nav_settings"
android:orderInCategory="4"
android:title="@string/actionbar_settings"/>
<item
android:id="@+id/nav_community"
android:icon="@drawable/nav_community"
android:orderInCategory="4"
android:title="@string/drawer_community" />
<item
android:id="@+id/nav_logout"
android:icon="@drawable/nav_logout"
android:orderInCategory="4"
android:title="@string/drawer_logout"/>
</group>

<!--
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@
<string name="drawer_item_uploads_list">Uploads</string>
<string name="drawer_logout">Abmelden</string>
<string name="drawer_open">Hauptmenü öffnen</string>
<string name="drawer_item_recent_files">Neuste Dateien</string>
<string name="drawer_quota">%1$s von %2$s verwendet</string>
<string name="drawer_quota_unlimited">%1$s verwendet</string>
<string name="drawer_quota_percentage">Speicher zu %d %% belegt</string>
<string name="drawer_quota_usage">%1$s von %2$s</string>
<string name="drawer_synced_folders">Automatisches Hochladen</string>
<string name="e2e_not_yet_setup">E2E bislang nicht eingerichtet</string>
<string name="e2e_offline">Ohne Internetverbindung nicht möglich</string>
Expand Down
64 changes: 64 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,68 @@
<!-- App bar -->
<color name="appbar">#1E1E1E</color>
<color name="fontAppbar">@android:color/white</color>

<!-- NMC Colors -->
<color name="icon_color">#FFFFFF</color>
<color name="sort_text_color">@color/grey_30</color>
<color name="list_icon_color">@color/grey_30</color>
<color name="warning_icon_color">#CCCCCC</color>
<color name="divider_color">@color/grey_70</color>
<color name="spinner_bg_color">@color/grey_80</color>
<color name="refresh_layout_bg_color">#2D2D2D</color>
<color name="primary_button_disabled_color">@color/grey_70</color>
<color name="toolbar_divider_color">@color/grey_70</color>

<!-- Snackbar Colors -->
<color name="snackbar_bg_color">@color/grey_80</color>
<color name="snackbar_txt_color">@color/grey_0</color>

<!-- Alert Dialog Colors -->
<color name="alert_bg_color">@color/grey_80</color>
<color name="alert_txt_color">@color/grey_0</color>

<!-- NavigationView colors -->
<color name="nav_selected_bg_color">@color/grey_60</color>
<color name="nav_txt_unselected_color">@color/grey_0</color>
<color name="nav_txt_selected_color">@color/grey_0</color>
<color name="nav_icon_unselected_color">@color/grey_30</color>
<color name="nav_icon_selected_color">#FFFFFF</color>
<color name="nav_divider_color">@color/grey_30</color>
<color name="nav_bg_color">@color/grey_80</color>
<color name="drawer_quota_txt_color">#FFFFFF</color>

<!-- Bottom Sheet Colors -->
<color name="bottom_sheet_bg_color">@color/grey_80</color>
<color name="bottom_sheet_icon_color">@color/grey_30</color>
<color name="bottom_sheet_txt_color">@color/grey_0</color>

<!-- Popup Menu Colors -->
<color name="popup_menu_bg">@color/grey_80</color>
<color name="popup_menu_txt_color">@color/grey_0</color>
<color name="overflow_bg_color">@color/grey_80</color>

<!-- Switch Compat Colors -->
<color name="switch_thumb_disabled">@color/grey_70</color>
<color name="switch_track_disabled">@color/grey_60</color>

<!-- Checkbox Colors -->
<color name="checkbox_checked_disabled">@color/grey_70</color>
<color name="checkbox_unchecked_disabled">@color/grey_70</color>

<!-- Share Colors -->
<color name="share_title_txt_color">#FFFFFF</color>
<color name="share_subtitle_txt_color">@color/grey_30</color>
<color name="share_info_txt_color">@color/grey_0</color>
<color name="share_search_border_color">@color/grey_0</color>
<color name="share_btn_txt_color">@color/grey_0</color>
<color name="share_list_item_txt_color">@color/grey_0</color>
<color name="share_disabled_txt_color">@color/grey_60</color>
<color name="share_txt_color">@color/grey_0</color>
<color name="share_et_divider">#FFFFFF</color>

<!-- Scan Colors -->
<color name="scan_doc_bg_color">#121212</color>
<color name="scan_text_color">@color/grey_0</color>
<color name="scan_edit_bottom_color">@color/grey_80</color>
<color name="scan_count_bg_color">@color/grey_80</color>
</resources>
Loading