Jelajahi Sumber

only show folder path on topo with synced folder made bold

AndyScherzinger 8 tahun lalu
induk
melakukan
a72056161c

+ 5 - 42
res/layout/folder_sync_settings_layout.xml

@@ -47,11 +47,13 @@
                 android:textAppearance="@style/TextAppearance.AppCompat.Title"/>
 
             <TextView
-                android:id="@+id/folder_sync_settings_subtitle"
+                android:id="@+id/folder_sync_settings_local_folder_path"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
-                android:text="@string/placeholder_filename"
-                android:textSize="@dimen/two_line_primary_text_size"/>
+                android:ellipsize="middle"
+                android:maxLines="2"
+                android:text="@string/folder_sync_preferences_folder_path"
+                android:textColor="?android:attr/textColorSecondary"/>
 
         </LinearLayout>
 
@@ -86,45 +88,6 @@
             android:layout_height="wrap_content"
             android:orientation="vertical">
 
-            <LinearLayout
-                android:id="@+id/local_folder_container"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:baselineAligned="false"
-                android:gravity="center_vertical"
-                android:minHeight="?android:attr/listPreferredItemHeightSmall">
-
-                <RelativeLayout
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="1"
-                    android:paddingBottom="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_padding">
-
-                    <TextView
-                        android:id="@+id/local_folder_title"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:maxLines="1"
-                        android:text="@string/prefs_folder_sync_local_path_title"
-                        android:textAppearance="?android:attr/textAppearanceListItem"
-                        android:textColor="?android:attr/textColorSecondary"/>
-
-                    <TextView
-                        android:id="@+id/local_folder_summary"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_alignLeft="@id/local_folder_title"
-                        android:layout_below="@id/local_folder_title"
-                        android:ellipsize="middle"
-                        android:maxLines="2"
-                        android:text="@string/placeholder_filename"
-                        android:textColor="?android:attr/textColorSecondary"/>
-
-                </RelativeLayout>
-
-            </LinearLayout>
-
             <LinearLayout
                 android:id="@+id/remote_folder_container"
                 android:layout_width="match_parent"

+ 1 - 0
res/values/strings.xml

@@ -504,6 +504,7 @@
     <string name="folder_sync_preferences">Instant Upload Preferences</string>
     <string name="folder_sync_settings">Settings</string>
     <string name="folder_sync_new_info">Instant upload has been revamped completely. Please see the main menu and re-configure your instant upload. Sorry for the inconvenience.\n\nEnjoy the new and extended instant upload capabilities!</string>
+    <string name="folder_sync_preferences_folder_path">For %1$s</string>
     <plurals name="items_selected_count">
         <!--
              As a developer, you should always supply "one" and "other"

+ 14 - 6
src/com/owncloud/android/ui/dialog/SyncedFolderPreferencesDialogFragment.java

@@ -24,11 +24,13 @@ import android.app.Activity;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.graphics.Typeface;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.v4.app.DialogFragment;
 import android.support.v7.app.AlertDialog;
 import android.support.v7.widget.SwitchCompat;
+import android.text.style.StyleSpan;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -41,6 +43,7 @@ import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.ui.activity.FolderPickerActivity;
 import com.owncloud.android.ui.dialog.parcel.SyncedFolderParcelable;
+import com.owncloud.android.utils.DisplayUtils;
 
 /**
  * Dialog to show the preferences/configuration of a synced folder allowing the user to change the different parameters.
@@ -59,8 +62,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
     private CheckBox mUploadOnChargingCheckbox;
     private CheckBox mUploadUseSubfoldersCheckbox;
     private TextView mUploadBehaviorSummary;
-    private TextView mLocalFolderName;
-    private TextView mLocalFolderSummary;
+    private TextView mLocalFolderPath;
     private TextView mRemoteFolderSummary;
 
     private SyncedFolderParcelable mSyncedFolder;
@@ -121,9 +123,9 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
      */
     private void setupDialogElements(View view) {
         // find/saves UI elements
-        mLocalFolderName = (TextView )view.findViewById(R.id.folder_sync_settings_subtitle);
         mEnabledSwitch = (SwitchCompat) view.findViewById(R.id.sync_enabled);
-        mLocalFolderSummary = (TextView) view.findViewById(R.id.local_folder_summary);
+        mLocalFolderPath = (TextView) view.findViewById(R.id.folder_sync_settings_local_folder_path);
+
         mRemoteFolderSummary = (TextView) view.findViewById(R.id.remote_folder_summary);
 
         mUploadOnWifiCheckbox = (CheckBox) view.findViewById(R.id.setting_instant_upload_on_wifi_checkbox);
@@ -135,8 +137,14 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
 
         // Set values
         setEnabled(mSyncedFolder.getEnabled());
-        mLocalFolderName.setText(mSyncedFolder.getFolderName());
-        mLocalFolderSummary.setText(mSyncedFolder.getLocalPath());
+        mLocalFolderPath.setText(
+                DisplayUtils.createTextWithSpan(
+                        String.format(
+                                getString(R.string.folder_sync_preferences_folder_path),
+                                mSyncedFolder.getLocalPath()),
+                        mSyncedFolder.getFolderName(),
+                        new StyleSpan(Typeface.BOLD)));
+
         mRemoteFolderSummary.setText(mSyncedFolder.getRemotePath());
 
         mUploadOnWifiCheckbox.setChecked(mSyncedFolder.getWifiOnly());

+ 21 - 3
src/com/owncloud/android/utils/DisplayUtils.java

@@ -38,7 +38,10 @@ import android.support.annotation.ColorInt;
 import android.support.design.widget.Snackbar;
 import android.support.v4.app.FragmentActivity;
 import android.support.v4.content.ContextCompat;
+import android.text.Spannable;
+import android.text.SpannableStringBuilder;
 import android.text.format.DateUtils;
+import android.text.style.StyleSpan;
 import android.view.View;
 import android.widget.ProgressBar;
 import android.widget.SeekBar;
@@ -68,9 +71,9 @@ public class DisplayUtils {
 
     private static final String[] sizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
     private static final int[] sizeScales = { 0, 0, 1, 1, 1, 2, 2, 2, 2 };
-    public static final int RELATIVE_THRESHOLD_WARNING = 90;
-    public static final int RELATIVE_THRESHOLD_CRITICAL = 95;
-    public static final String MIME_TYPE_UNKNOWN = "Unknown type";
+    private static final int RELATIVE_THRESHOLD_WARNING = 90;
+    private static final int RELATIVE_THRESHOLD_CRITICAL = 95;
+    private static final String MIME_TYPE_UNKNOWN = "Unknown type";
 
     private static Map<String, String> mimeType2HumanReadable;
 
@@ -354,6 +357,21 @@ public class DisplayUtils {
         }
     }
 
+    /**
+     * styling of given spanText within a given text.
+     *
+     * @param text the non styled complete text
+     * @param spanText the to be styled text
+     * @param style the style to be applied
+     */
+    public static SpannableStringBuilder createTextWithSpan(String text, String spanText, StyleSpan style) {
+        SpannableStringBuilder sb = new SpannableStringBuilder(text);
+        int start = text.lastIndexOf(spanText);
+        int end = start + spanText.length();
+        sb.setSpan(style, start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+        return sb;
+    }
+
     /**
      * Sets the color of the progressbar to {@code color} within the given toolbar.
      *