Browse Source

making callback to context not view

Bartek Przybylski 13 years ago
parent
commit
a10efb1229

+ 0 - 30
res/layout/account_setup.xml

@@ -131,36 +131,6 @@
 
 
                 </eu.alefzero.owncloud.widgets.ActionEditText>
                 </eu.alefzero.owncloud.widgets.ActionEditText>
             </TableRow>
             </TableRow>
-            <TableRow android:id="@+id/tableRow5"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_horizontal"
-                android:weightSum="1.0">
-                
-                <CheckBox
-					android:id="@+id/show_password"
-					android:layout_width="fill_parent"
-					android:layout_height="wrap_content"
-					android:layout_weight=".75"
-					android:hint="@string/setup_hint_show_password"
-					android:textColor="@android:color/black"
-					android:onClick="onCheckboxClick"/>
-            </TableRow>
-            <TableRow android:id="@+id/tableRow6"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:gravity="center_horizontal"
-                android:weightSum="1.0">
-                
-                <CheckBox
-          android:id="@+id/use_ssl"
-          android:layout_width="fill_parent"
-          android:layout_height="wrap_content"
-          android:layout_weight=".75"
-          android:hint="@string/use_ssl"
-          android:textColor="@android:color/black"
-          android:onClick="onCheckboxClick"/>
-            </TableRow>
         </TableLayout>
         </TableLayout>
 
 
         <LinearLayout
         <LinearLayout

+ 9 - 23
src/eu/alefzero/owncloud/ui/activity/AuthenticatorActivity.java

@@ -225,29 +225,15 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity {
                 AuthenticatorActivity.this);
                 AuthenticatorActivity.this);
     }
     }
     
     
-    /**
-     * Handles the show password checkbox
-     * @author robstar
-     * @author aqu
-     * @param view
-     */
-    public void onCheckboxClick(View view) {
-      switch (view.getId()) {
-        case R.id.show_password:
-          TextView password_text = (TextView) findViewById(R.id.account_password);
-          
-          if(((CheckBox)view).isChecked()) {
-            password_text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
-          } else {
-            password_text.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
-          }
-        break;
-        case R.id.use_ssl:
-          mUseSSLConnection = ((CheckBox)view).isChecked();
-        break;
-        default:
-          Log.d("AuthActivity", "Clicked invalid view with id: " + view.getId());
+    public void sslBadgeClick(View view, String val) {
+      mUseSSLConnection = ((TextView)view).getText().equals("SSL");
+    }
+    
+    public void passwordBadgeClick(View view, String val) {
+      if(val.equals("Hide")) {
+        ((TextView)view).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
+      } else {
+        ((TextView)view).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
       }
       }
-    	
     }
     }
 }
 }

+ 5 - 19
src/eu/alefzero/owncloud/widgets/ActionEditText.java

@@ -86,23 +86,22 @@ public class ActionEditText extends EditText {
           paramtypes[1] = String.class;
           paramtypes[1] = String.class;
           Method method;
           Method method;
           try {
           try {
-            method = this.getClass().getMethod(badgeClickCallback, paramtypes);
-            method.invoke(this, this, s);
+
+            method = getContext().getClass().getMethod(badgeClickCallback, paramtypes);
+            method.invoke(getContext(), this, s);
+
           } catch (NoSuchMethodException e) {
           } catch (NoSuchMethodException e) {
             e.printStackTrace();
             e.printStackTrace();
           } catch (IllegalArgumentException e) {
           } catch (IllegalArgumentException e) {
-            // TODO Auto-generated catch block
             e.printStackTrace();
             e.printStackTrace();
           } catch (IllegalAccessException e) {
           } catch (IllegalAccessException e) {
-            // TODO Auto-generated catch block
             e.printStackTrace();
             e.printStackTrace();
           } catch (InvocationTargetException e) {
           } catch (InvocationTargetException e) {
-            // TODO Auto-generated catch block
             e.printStackTrace();
             e.printStackTrace();
           }
           }
           
           
+          invalidate();
         }
         }
-        invalidate();
       }
       }
     }
     }
     return r;
     return r;
@@ -117,17 +116,4 @@ public class ActionEditText extends EditText {
     badgeClickCallback = a.getString(R.styleable.ActionEditText_onBadgeClick);
     badgeClickCallback = a.getString(R.styleable.ActionEditText_onBadgeClick);
   }
   }
   
   
-  public void sslBadgeClick(View view, String val) {
-    Log.d("ASD", val);
-  }
-  
-  public void passwordBadgeClick(View view, String val) {
-    
-    if(val.equals("Hide")) {
-      ((TextView)view).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
-    } else {
-      ((TextView)view).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
-    }
-  }
-  
 }
 }