Use new FoldableLinearLayout in API settings

This commit is contained in:
Dominik Schürmann 2014-03-23 00:03:49 +01:00
parent 14dab821b7
commit 153b99a186
2 changed files with 15 additions and 59 deletions

View File

@ -25,13 +25,13 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.AlphaAnimation; import android.widget.AdapterView;
import android.view.animation.Animation;
import android.widget.*;
import android.widget.AdapterView.OnItemSelectedListener; import android.widget.AdapterView.OnItemSelectedListener;
import com.beardedhen.androidbootstrap.BootstrapButton; import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import org.spongycastle.util.encoders.Hex; import org.spongycastle.util.encoders.Hex;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
@ -50,8 +50,6 @@ public class AppSettingsFragment extends Fragment implements
private AppSettings mAppSettings; private AppSettings mAppSettings;
// view // view
private LinearLayout mAdvancedSettingsContainer;
private BootstrapButton mAdvancedSettingsButton;
private TextView mAppNameView; private TextView mAppNameView;
private ImageView mAppIconView; private ImageView mAppIconView;
private Spinner mEncryptionAlgorithm; private Spinner mEncryptionAlgorithm;
@ -117,11 +115,6 @@ public class AppSettingsFragment extends Fragment implements
R.id.api_app_settings_select_key_fragment); R.id.api_app_settings_select_key_fragment);
mSelectKeyFragment.setCallback(this); mSelectKeyFragment.setCallback(this);
mAdvancedSettingsButton = (BootstrapButton) view
.findViewById(R.id.api_app_settings_advanced_button);
mAdvancedSettingsContainer = (LinearLayout) view
.findViewById(R.id.api_app_settings_advanced);
mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name); mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name);
mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon);
mEncryptionAlgorithm = (Spinner) view mEncryptionAlgorithm = (Spinner) view
@ -176,35 +169,6 @@ public class AppSettingsFragment extends Fragment implements
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
} }
}); });
final Animation visibleAnimation = new AlphaAnimation(0.0f, 1.0f);
visibleAnimation.setDuration(250);
final Animation invisibleAnimation = new AlphaAnimation(1.0f, 0.0f);
invisibleAnimation.setDuration(250);
// TODO: Better: collapse/expand animation
// final Animation animation2 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
// Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f,
// Animation.RELATIVE_TO_SELF, 0.0f);u
// animation2.setDuration(150);
mAdvancedSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mAdvancedSettingsContainer.getVisibility() == View.VISIBLE) {
mAdvancedSettingsContainer.startAnimation(invisibleAnimation);
mAdvancedSettingsContainer.setVisibility(View.GONE);
mAdvancedSettingsButton.setText(getString(R.string.api_settings_show_advanced));
mAdvancedSettingsButton.setLeftIcon("fa-caret-up");
} else {
mAdvancedSettingsContainer.startAnimation(visibleAnimation);
mAdvancedSettingsContainer.setVisibility(View.VISIBLE);
mAdvancedSettingsButton.setText(getString(R.string.api_settings_hide_advanced));
mAdvancedSettingsButton.setLeftIcon("fa-caret-down");
}
}
});
} }
private void setPackage(String packageName) { private void setPackage(String packageName) {

View File

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
@ -42,24 +43,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
tools:layout="@layout/select_secret_key_layout_fragment" /> tools:layout="@layout/select_secret_key_layout_fragment" />
<com.beardedhen.androidbootstrap.BootstrapButton <org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout
android:id="@+id/api_app_settings_advanced_button"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="center_vertical" custom:foldedLabel="@string/btn_encryption_advanced_settings_show"
android:layout_marginBottom="4dp" custom:unFoldedLabel="@string/btn_encryption_advanced_settings_hide"
android:layout_marginTop="4dp" custom:foldedIcon="fa-chevron-right"
android:text="@string/api_settings_show_advanced" custom:unFoldedIcon="fa-chevron-down">
bootstrapbutton:bb_icon_left="fa-caret-up"
bootstrapbutton:bb_size="default"
bootstrapbutton:bb_type="default" />
<LinearLayout
android:id="@+id/api_app_settings_advanced"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -119,5 +109,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Base64 encoded signature" android:text="Base64 encoded signature"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</org.sufficientlysecure.keychain.ui.widget.FoldableLinearLayout>
</LinearLayout> </LinearLayout>