1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package org.sufficientlysecure.keychain.remote_api;
import org.sufficientlysecure.keychain.Id;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.SelectSecretKeyActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.LinearLayout;
public class AppSettingsFragment extends Fragment {
private LinearLayout advancedSettingsContainer;
private Button advancedSettingsButton;
/**
* Inflate the layout for this fragment
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.api_app_settings_fragment, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
advancedSettingsButton = (Button) getActivity().findViewById(
R.id.api_app_settings_advanced_button);
advancedSettingsContainer = (LinearLayout) getActivity().findViewById(
R.id.api_app_settings_advanced);
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);
// animation2.setDuration(150);
advancedSettingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (advancedSettingsContainer.getVisibility() == View.VISIBLE) {
advancedSettingsContainer.startAnimation(invisibleAnimation);
advancedSettingsContainer.setVisibility(View.INVISIBLE);
advancedSettingsButton.setText(R.string.api_settings_show_advanced);
} else {
advancedSettingsContainer.startAnimation(visibleAnimation);
advancedSettingsContainer.setVisibility(View.VISIBLE);
advancedSettingsButton.setText(R.string.api_settings_hide_advanced);
}
}
});
}
}
|