Skip to content
This repository
Browse code

UX tweak, don't show fiddly fields until the Clone url is populated

Establishing the clone-url is always going to be the user's first priority,
so don't distract them with other fields until they've made headway on that
task.

This tweak is only enabled on Honeycomb and above, ie where the gentle
LayoutTransition animation is available. The change is too distracting if
it occurs instantly without animated fade-in.
  • Loading branch information...
commit a7f1567230c9a2cd5e9b54edc502645032810e25 1 parent 9c05a83
Roberto Tyley authored
45  agit/res/layout/clone_launcher.xml
@@ -14,6 +14,7 @@
14 14
                 android:orientation="vertical"
15 15
                 android:layout_width="match_parent"
16 16
                 android:layout_height="match_parent"
  17
+                android:animateLayoutChanges="true"
17 18
                 android:paddingLeft="14dip" android:paddingRight="14dip"
18 19
                 android:paddingTop="6dip" android:paddingBottom="6dip">
19 20
 
@@ -28,6 +29,7 @@
28 29
 
29 30
             <TextView
30 31
                     android:id="@+id/ProtocolLabel"
  32
+                    android:visibility="invisible"
31 33
                     android:layout_gravity="right"
32 34
                     android:background="@drawable/label_background"
33 35
                     android:textStyle="bold"
@@ -36,24 +38,31 @@
36 38
                     android:layout_width="wrap_content"
37 39
                     android:layout_height="wrap_content"/>
38 40
 
39  
-            <TextView
40  
-                    android:layout_width="fill_parent"
41  
-                    android:layout_height="wrap_content"
42  
-                    android:text="@string/clone_target_folder_label"/>
43  
-            <EditText
44  
-                    android:id="@+id/GitDirEditText"
45  
-                    android:layout_height="wrap_content"
46  
-                    android:layout_width="fill_parent"
47  
-                    android:hint="@string/clone_directory_hint"
48  
-                    android:inputType="textUri"/>
49  
-            <CheckBox android:id="@+id/UseDefaultGitDirLocation"
50  
-                      android:layout_width="wrap_content" android:layout_height="wrap_content"
51  
-                      android:text="@string/use_default_target_directory_checkbox_label"
52  
-                      android:checked="true"/>
53  
-            <CheckBox android:id="@+id/BareRepo"
54  
-                      android:layout_width="wrap_content" android:layout_height="wrap_content"
55  
-                      android:text="@string/bare_repo_checkbox_label"
56  
-                      android:checked="true"/>
  41
+            <LinearLayout android:id="@+id/secondary_details"
  42
+                    android:visibility="invisible"
  43
+                    android:orientation="vertical"
  44
+                    android:layout_width="match_parent"
  45
+                    android:layout_height="match_parent">
  46
+
  47
+                <TextView
  48
+                        android:layout_width="fill_parent"
  49
+                        android:layout_height="wrap_content"
  50
+                        android:text="@string/clone_target_folder_label"/>
  51
+                <EditText
  52
+                        android:id="@+id/GitDirEditText"
  53
+                        android:layout_height="wrap_content"
  54
+                        android:layout_width="fill_parent"
  55
+                        android:hint="@string/clone_directory_hint"
  56
+                        android:inputType="textUri"/>
  57
+                <CheckBox android:id="@+id/UseDefaultGitDirLocation"
  58
+                          android:layout_width="wrap_content" android:layout_height="wrap_content"
  59
+                          android:text="@string/use_default_target_directory_checkbox_label"
  60
+                          android:checked="true"/>
  61
+                <CheckBox android:id="@+id/BareRepo"
  62
+                          android:layout_width="wrap_content" android:layout_height="wrap_content"
  63
+                          android:text="@string/bare_repo_checkbox_label"
  64
+                          android:checked="true"/>
  65
+            </LinearLayout>
57 66
         </LinearLayout>
58 67
     </ScrollView>
59 68
     <RelativeLayout style="@style/ExecutionBar" android:gravity="right">
19  agit/src/main/java/com/madgag/agit/CloneLauncherActivity.java
@@ -20,6 +20,7 @@
20 20
 package com.madgag.agit;
21 21
 
22 22
 import static android.content.pm.PackageManager.PERMISSION_GRANTED;
  23
+import static android.os.Build.VERSION_CODES.HONEYCOMB;
23 24
 import static android.view.View.INVISIBLE;
24 25
 import static android.view.View.VISIBLE;
25 26
 import static android.widget.Toast.LENGTH_LONG;
@@ -34,6 +35,7 @@
34 35
 import static com.madgag.agit.git.TransportProtocols.niceProtocolNameFor;
35 36
 import static org.eclipse.jgit.lib.Constants.DOT_GIT_EXT;
36 37
 import android.content.Intent;
  38
+import android.os.Build;
37 39
 import android.os.Bundle;
38 40
 import android.os.Environment;
39 41
 import android.text.Editable;
@@ -43,6 +45,7 @@
43 45
 import android.util.Log;
44 46
 import android.view.View;
45 47
 import android.view.View.OnClickListener;
  48
+import android.view.ViewGroup;
46 49
 import android.widget.Button;
47 50
 import android.widget.CheckBox;
48 51
 import android.widget.CompoundButton;
@@ -72,6 +75,8 @@ public static Intent cloneLauncherIntentFor(String sourceUri) {
72 75
         return new GitIntentBuilder("clone.PREPARE").sourceUri(sourceUri).toIntent();
73 76
     }
74 77
 
  78
+    private final boolean layoutTransitionAvailable = Build.VERSION.SDK_INT >= HONEYCOMB;
  79
+
75 80
     @InjectView(R.id.BareRepo)
76 81
     CheckBox bareRepoCheckbox;
77 82
     @InjectView(R.id.GoCloneButton)
@@ -80,6 +85,10 @@ public static Intent cloneLauncherIntentFor(String sourceUri) {
80 85
     CheckBox useDefaultGitDirLocationButton;
81 86
     @InjectView(R.id.ProtocolLabel)
82 87
     TextView protocolLabel;
  88
+
  89
+    @InjectView(R.id.secondary_details)
  90
+    ViewGroup secondaryDetailsGroup;
  91
+
83 92
     @InjectView(R.id.CloneReadinessMessage)
84 93
     TextView cloneReadinessMessageView;
85 94
     @InjectView(R.id.GitDirEditText)
@@ -130,9 +139,17 @@ protected void updateUIWithValidation() {
130 139
         String cloneUriText = getCloneUriText();
131 140
         Log.d(TAG, "cloneUriText=" + cloneUriText);
132 141
         CharSequence message = null;
133  
-        if (cloneUriText.length() <= 3) {
  142
+
  143
+        boolean cloneUrlPopulated = cloneUriText.length() > 3;
  144
+
  145
+        // GONE causes jerky animation with the 1st layout transition here, I think because of the initial resize
  146
+        secondaryDetailsGroup.setVisibility((cloneUrlPopulated || !layoutTransitionAvailable)?VISIBLE:INVISIBLE);
  147
+
  148
+        if (!cloneUrlPopulated) {
  149
+            enableClone = false;
134 150
             message = getString(R.string.clone_readiness_needs_user_to_enter_a_url);
135 151
         }
  152
+
136 153
         URIish cloneUri = null;
137 154
         String transportProtocol = null;
138 155
         try {

0 notes on commit a7f1567

Please sign in to comment.
Something went wrong with that request. Please try again.