parent
3bd360a7ee
commit
86623c634a
@ -0,0 +1,107 @@ |
||||
package com.keylesspalace.tusky; |
||||
|
||||
import android.os.Bundle; |
||||
import android.os.Parcelable; |
||||
import android.support.annotation.Nullable; |
||||
import android.support.design.widget.BottomSheetDialogFragment; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
import android.widget.CheckBox; |
||||
import android.widget.CompoundButton; |
||||
import android.widget.RadioGroup; |
||||
|
||||
public class ComposeOptionsFragment extends BottomSheetDialogFragment { |
||||
public interface Listener extends Parcelable { |
||||
void onVisibilityChanged(String visibility); |
||||
void onMarkSensitiveChanged(boolean markSensitive); |
||||
void onContentWarningChanged(boolean hideText); |
||||
} |
||||
|
||||
private Listener listener; |
||||
|
||||
public static ComposeOptionsFragment newInstance(String visibility, boolean markSensitive, |
||||
boolean hideText, boolean showMarkSensitive, Listener listener) { |
||||
Bundle arguments = new Bundle(); |
||||
ComposeOptionsFragment fragment = new ComposeOptionsFragment(); |
||||
arguments.putParcelable("listener", listener); |
||||
arguments.putString("visibility", visibility); |
||||
arguments.putBoolean("markSensitive", markSensitive); |
||||
arguments.putBoolean("hideText", hideText); |
||||
arguments.putBoolean("showMarkSensitive", showMarkSensitive); |
||||
fragment.setArguments(arguments); |
||||
return fragment; |
||||
} |
||||
|
||||
@Nullable |
||||
@Override |
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, |
||||
@Nullable Bundle savedInstanceState) { |
||||
View rootView = inflater.inflate(R.layout.fragment_compose_options, container, false); |
||||
|
||||
Bundle arguments = getArguments(); |
||||
listener = arguments.getParcelable("listener"); |
||||
String statusVisibility = arguments.getString("visibility"); |
||||
boolean statusMarkSensitive = arguments.getBoolean("markSensitive"); |
||||
boolean statusHideText = arguments.getBoolean("hideText"); |
||||
boolean showMarkSensitive = arguments.getBoolean("showMarkSensitive"); |
||||
|
||||
RadioGroup radio = (RadioGroup) rootView.findViewById(R.id.radio_visibility); |
||||
int radioCheckedId = R.id.radio_public; |
||||
if (statusVisibility != null) { |
||||
if (statusVisibility.equals("unlisted")) { |
||||
radioCheckedId = R.id.radio_unlisted; |
||||
} else if (statusVisibility.equals("private")) { |
||||
radioCheckedId = R.id.radio_private; |
||||
} |
||||
} |
||||
radio.check(radioCheckedId); |
||||
radio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { |
||||
@Override |
||||
public void onCheckedChanged(RadioGroup group, int checkedId) { |
||||
String visibility; |
||||
switch (checkedId) { |
||||
default: |
||||
case R.id.radio_public: { |
||||
visibility = "public"; |
||||
break; |
||||
} |
||||
case R.id.radio_unlisted: { |
||||
visibility = "unlisted"; |
||||
break; |
||||
} |
||||
case R.id.radio_private: { |
||||
visibility = "private"; |
||||
break; |
||||
} |
||||
} |
||||
listener.onVisibilityChanged(visibility); |
||||
} |
||||
}); |
||||
|
||||
CheckBox markSensitive = (CheckBox) rootView.findViewById(R.id.compose_mark_sensitive); |
||||
if (showMarkSensitive) { |
||||
markSensitive.setChecked(statusMarkSensitive); |
||||
markSensitive.setEnabled(true); |
||||
markSensitive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
||||
@Override |
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
||||
listener.onMarkSensitiveChanged(isChecked); |
||||
} |
||||
}); |
||||
} else { |
||||
markSensitive.setEnabled(false); |
||||
} |
||||
|
||||
CheckBox hideText = (CheckBox) rootView.findViewById(R.id.compose_hide_text); |
||||
hideText.setChecked(statusHideText); |
||||
hideText.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
||||
@Override |
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
||||
listener.onContentWarningChanged(isChecked); |
||||
} |
||||
}); |
||||
|
||||
return rootView; |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<corners android:radius="3dp" /> |
||||
<stroke android:color="#ff000000" android:width="1dp" /> |
||||
</shape> |
@ -0,0 +1,7 @@ |
||||
<vector android:height="24dp" android:viewportHeight="1133.8583" |
||||
android:viewportWidth="1133.8583" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> |
||||
<path android:fillAlpha="1" android:fillColor="#00000000" |
||||
android:pathData="M704.8,566.9A137.9,137.9 0,0 1,566.9 704.8,137.9 137.9,0 0,1 429,566.9 137.9,137.9 0,0 1,566.9 429,137.9 137.9,0 0,1 704.8,566.9ZM566.9,1098.1c-184.7,0 -26,-116.8 -185.9,-209.2 -160,-92.4 -181.8,103.5 -274.1,-56.4 -92.4,-160 88.2,-80.9 88.2,-265.6 0,-184.7 -180.5,-105.6 -88.2,-265.6 92.4,-160 114.1,35.9 274.1,-56.4 160,-92.4 1.2,-209.2 185.9,-209.2 184.7,-0 26,116.8 185.9,209.2 160,92.4 181.8,-103.5 274.1,56.4 92.4,160 -88.2,80.9 -88.2,265.6 0,184.7 180.5,105.6 88.2,265.6C934.6,992.5 912.8,796.6 752.8,888.9 592.9,981.3 751.6,1098.1 566.9,1098.1Z" |
||||
android:strokeAlpha="1" android:strokeColor="#000000" |
||||
android:strokeLineCap="butt" android:strokeLineJoin="round" android:strokeWidth="68.95068359"/> |
||||
</vector> |
@ -0,0 +1,52 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:orientation="vertical" |
||||
android:layout_width="match_parent" |
||||
android:layout_height="match_parent"> |
||||
|
||||
<RadioGroup |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:orientation="vertical" |
||||
android:id="@+id/radio_visibility" |
||||
android:checkedButton="@+id/radio_public" |
||||
android:layout_margin="@dimen/compose_options_margin"> |
||||
|
||||
<RadioButton |
||||
android:text="@string/visibility_public" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:id="@+id/radio_public" |
||||
android:layout_weight="1" /> |
||||
|
||||
<RadioButton |
||||
android:text="@string/visibility_unlisted" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:id="@+id/radio_unlisted" |
||||
android:layout_weight="1" /> |
||||
|
||||
<RadioButton |
||||
android:text="@string/visibility_private" |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:id="@+id/radio_private" |
||||
android:layout_weight="1" /> |
||||
|
||||
</RadioGroup> |
||||
|
||||
<CheckBox |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:layout_margin="@dimen/compose_options_margin" |
||||
android:id="@+id/compose_mark_sensitive" |
||||
android:text="@string/action_mark_sensitive" /> |
||||
|
||||
<CheckBox |
||||
android:layout_width="wrap_content" |
||||
android:layout_height="match_parent" |
||||
android:layout_margin="@dimen/compose_options_margin" |
||||
android:id="@+id/compose_hide_text" |
||||
android:text="@string/action_hide_text" /> |
||||
|
||||
</LinearLayout> |
Loading…
Reference in new issue