Skip to content

Commit fbc00b1

Browse files
New UI design in CreateMultiRedditActivity.
1 parent 464cc1c commit fbc00b1

File tree

3 files changed

+138
-50
lines changed

3 files changed

+138
-50
lines changed

app/src/main/java/ml/docilealligator/infinityforreddit/activities/CreateMultiRedditActivity.java

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import android.content.Intent;
44
import android.content.SharedPreferences;
5+
import android.content.res.ColorStateList;
56
import android.os.Build;
67
import android.os.Bundle;
78
import android.os.Handler;
89
import android.view.Menu;
910
import android.view.MenuItem;
1011
import android.view.View;
12+
import android.widget.CompoundButton;
1113

1214
import androidx.annotation.NonNull;
1315
import androidx.annotation.Nullable;
@@ -26,11 +28,9 @@
2628
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
2729
import ml.docilealligator.infinityforreddit.account.Account;
2830
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
29-
import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr;
3031
import ml.docilealligator.infinityforreddit.databinding.ActivityCreateMultiRedditBinding;
3132
import ml.docilealligator.infinityforreddit.multireddit.CreateMultiReddit;
3233
import ml.docilealligator.infinityforreddit.multireddit.MultiRedditJSONModel;
33-
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
3434
import ml.docilealligator.infinityforreddit.utils.Utils;
3535
import retrofit2.Retrofit;
3636

@@ -68,10 +68,6 @@ protected void onCreate(Bundle savedInstanceState) {
6868

6969
applyCustomTheme();
7070

71-
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
72-
Slidr.attach(this);
73-
}
74-
7571
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
7672
addOnOffsetChangedListener(binding.appbarLayoutCreateMultiRedditActivity);
7773
}
@@ -80,7 +76,7 @@ protected void onCreate(Bundle savedInstanceState) {
8076
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
8177

8278
if (accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
83-
binding.visibilityWrapperLinearLayoutCreateMultiRedditActivity.setVisibility(View.GONE);
79+
binding.visibilityChipCreateMultiRedditActivity.setVisibility(View.GONE);
8480
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
8581
binding.multiRedditNameEditTextCreateMultiRedditActivity.setImeOptions(binding.multiRedditNameEditTextCreateMultiRedditActivity.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
8682
binding.descriptionEditTextCreateMultiRedditActivity.setImeOptions(binding.descriptionEditTextCreateMultiRedditActivity.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
@@ -96,11 +92,23 @@ protected void onCreate(Bundle savedInstanceState) {
9692
}
9793

9894
private void bindView() {
99-
binding.selectSubredditTextViewCreateMultiRedditActivity.setOnClickListener(view -> {
95+
binding.selectSubredditChipCreateMultiRedditActivity.setOnClickListener(view -> {
10096
Intent intent = new Intent(CreateMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
10197
intent.putStringArrayListExtra(SelectedSubredditsAndUsersActivity.EXTRA_SELECTED_SUBREDDITS, mSubreddits);
10298
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
10399
});
100+
101+
binding.visibilityChipCreateMultiRedditActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
102+
@Override
103+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
104+
if (isChecked) {
105+
binding.visibilityChipCreateMultiRedditActivity.setChipBackgroundColor(ColorStateList.valueOf(mCustomThemeWrapper.getFilledCardViewBackgroundColor()));
106+
} else {
107+
//Match the background color
108+
binding.visibilityChipCreateMultiRedditActivity.setChipBackgroundColor(ColorStateList.valueOf(mCustomThemeWrapper.getBackgroundColor()));
109+
}
110+
}
111+
});
104112
}
105113

106114
@Override
@@ -124,7 +132,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
124132

125133
if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
126134
String jsonModel = new MultiRedditJSONModel(binding.multiRedditNameEditTextCreateMultiRedditActivity.getText().toString(), binding.descriptionEditTextCreateMultiRedditActivity.getText().toString(),
127-
binding.visibilitySwitchCreateMultiRedditActivity.isChecked(), mSubreddits).createJSONModel();
135+
binding.visibilityChipCreateMultiRedditActivity.isChecked(), mSubreddits).createJSONModel();
128136
CreateMultiReddit.createMultiReddit(mOauthRetrofit, mRedditDataRoomDatabase, accessToken,
129137
"/user/" + accountName + "/m/" + binding.multiRedditNameEditTextCreateMultiRedditActivity.getText().toString(),
130138
jsonModel, new CreateMultiReddit.CreateMultiRedditListener() {
@@ -200,19 +208,30 @@ protected void applyCustomTheme() {
200208
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutCreateMultiRedditActivity,
201209
binding.collapsingToolbarLayoutCreateMultiRedditActivity, binding.toolbarCreateMultiRedditActivity);
202210
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
203-
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
211+
binding.inputCardViewCreateMultiRedditActivity.setCardBackgroundColor(mCustomThemeWrapper.getFilledCardViewBackgroundColor());
212+
213+
binding.multiRedditNameExplanationTextInputLayoutCreateMultiRedditActivity.setTextColor(primaryTextColor);
214+
binding.multiRedditNameTextInputLayoutCreateMultiRedditActivity.setBoxStrokeColor(primaryTextColor);
215+
binding.multiRedditNameTextInputLayoutCreateMultiRedditActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
204216
binding.multiRedditNameEditTextCreateMultiRedditActivity.setTextColor(primaryTextColor);
205-
binding.multiRedditNameEditTextCreateMultiRedditActivity.setHintTextColor(secondaryTextColor);
206-
int dividerColor = mCustomThemeWrapper.getDividerColor();
207-
binding.divider1CreateMultiRedditActivity.setBackgroundColor(dividerColor);
208-
binding.divider2CreateMultiRedditActivity.setBackgroundColor(dividerColor);
217+
218+
binding.descriptionTextInputLayoutCreateMultiRedditActivity.setBoxStrokeColor(primaryTextColor);
219+
binding.descriptionTextInputLayoutCreateMultiRedditActivity.setDefaultHintTextColor(ColorStateList.valueOf(primaryTextColor));
209220
binding.descriptionEditTextCreateMultiRedditActivity.setTextColor(primaryTextColor);
210-
binding.descriptionEditTextCreateMultiRedditActivity.setHintTextColor(secondaryTextColor);
211-
binding.visibilityTextViewCreateMultiRedditActivity.setTextColor(primaryTextColor);
212-
binding.selectSubredditTextViewCreateMultiRedditActivity.setTextColor(primaryTextColor);
221+
222+
223+
binding.selectSubredditChipCreateMultiRedditActivity.setTextColor(primaryTextColor);
224+
binding.selectSubredditChipCreateMultiRedditActivity.setChipBackgroundColor(ColorStateList.valueOf(mCustomThemeWrapper.getFilledCardViewBackgroundColor()));
225+
binding.selectSubredditChipCreateMultiRedditActivity.setChipStrokeColor(ColorStateList.valueOf(mCustomThemeWrapper.getFilledCardViewBackgroundColor()));
226+
227+
binding.visibilityChipCreateMultiRedditActivity.setTextColor(primaryTextColor);
228+
binding.visibilityChipCreateMultiRedditActivity.setChipBackgroundColor(ColorStateList.valueOf(mCustomThemeWrapper.getFilledCardViewBackgroundColor()));
229+
binding.visibilityChipCreateMultiRedditActivity.setChipStrokeColor(ColorStateList.valueOf(mCustomThemeWrapper.getFilledCardViewBackgroundColor()));
213230

214231
if (typeface != null) {
215232
Utils.setFontToAllTextViews(binding.coordinatorLayoutCreateMultiRedditActivity, typeface);
233+
binding.selectSubredditChipCreateMultiRedditActivity.setTypeface(typeface);
234+
binding.visibilityChipCreateMultiRedditActivity.setTypeface(typeface);
216235
}
217236
}
218237
}

app/src/main/res/layout/activity_create_multi_reddit.xml

Lines changed: 101 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,46 +43,116 @@
4343
android:layout_height="wrap_content"
4444
android:orientation="vertical">
4545

46-
<EditText
47-
android:id="@+id/multi_reddit_name_edit_text_create_multi_reddit_activity"
46+
<com.google.android.material.card.MaterialCardView
47+
android:id="@+id/input_card_view_create_multi_reddit_activity"
48+
style="?attr/materialCardViewFilledStyle"
4849
android:layout_width="match_parent"
4950
android:layout_height="wrap_content"
50-
android:padding="16dp"
51-
android:hint="@string/multi_reddit_name_hint"
52-
android:inputType="textMultiLine"
53-
android:textSize="?attr/font_default"
54-
android:background="#00000000"
55-
android:textColor="?attr/primaryTextColor"
56-
android:fontFamily="?attr/font_family"
57-
android:maxLength="50" />
58-
59-
<View
60-
android:id="@+id/divider_1_create_multi_reddit_activity"
61-
android:layout_width="match_parent"
62-
android:layout_height="1dp" />
51+
android:layout_marginTop="16dp"
52+
android:layout_marginStart="16dp"
53+
android:layout_marginEnd="16dp"
54+
app:cardCornerRadius="12dp">
6355

64-
<EditText
65-
android:id="@+id/description_edit_text_create_multi_reddit_activity"
56+
<LinearLayout
57+
android:layout_width="match_parent"
58+
android:layout_height="wrap_content"
59+
android:orientation="vertical">
60+
61+
<TextView
62+
android:id="@+id/multi_reddit_name_explanation_text_input_layout_create_multi_reddit_activity"
63+
android:layout_width="match_parent"
64+
android:layout_height="wrap_content"
65+
android:paddingTop="16dp"
66+
android:paddingBottom="8dp"
67+
android:paddingStart="16dp"
68+
android:paddingEnd="16dp"
69+
android:text="@string/multi_reddit_name_explanation"
70+
android:textSize="?attr/font_default"
71+
android:textColor="?attr/primaryTextColor"
72+
android:fontFamily="?attr/font_family" />
73+
74+
<com.google.android.material.textfield.TextInputLayout
75+
android:id="@+id/multi_reddit_name_text_input_layout_create_multi_reddit_activity"
76+
android:layout_width="match_parent"
77+
android:layout_height="wrap_content"
78+
android:paddingTop="8dp"
79+
android:paddingBottom="8dp"
80+
android:paddingStart="16dp"
81+
android:paddingEnd="16dp"
82+
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
83+
84+
<com.google.android.material.textfield.TextInputEditText
85+
android:id="@+id/multi_reddit_name_edit_text_create_multi_reddit_activity"
86+
android:layout_width="match_parent"
87+
android:layout_height="wrap_content"
88+
android:padding="16dp"
89+
android:hint="@string/multi_reddit_name_hint"
90+
android:inputType="textMultiLine"
91+
android:textSize="?attr/font_default"
92+
android:fontFamily="?attr/font_family"
93+
android:maxLength="50" />
94+
95+
</com.google.android.material.textfield.TextInputLayout>
96+
97+
<com.google.android.material.textfield.TextInputLayout
98+
android:id="@+id/description_text_input_layout_create_multi_reddit_activity"
99+
android:layout_width="match_parent"
100+
android:layout_height="wrap_content"
101+
android:paddingTop="8dp"
102+
android:paddingBottom="16dp"
103+
android:paddingStart="16dp"
104+
android:paddingEnd="16dp"
105+
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
106+
107+
<com.google.android.material.textfield.TextInputEditText
108+
android:id="@+id/description_edit_text_create_multi_reddit_activity"
109+
android:layout_width="match_parent"
110+
android:layout_height="wrap_content"
111+
android:padding="16dp"
112+
android:hint="@string/multi_reddit_description_hint"
113+
android:inputType="textMultiLine"
114+
android:textSize="?attr/font_default"
115+
android:fontFamily="?attr/font_family" />
116+
117+
</com.google.android.material.textfield.TextInputLayout>
118+
119+
</LinearLayout>
120+
121+
</com.google.android.material.card.MaterialCardView>
122+
123+
<com.google.android.material.chip.ChipGroup
66124
android:layout_width="match_parent"
67125
android:layout_height="wrap_content"
68126
android:padding="16dp"
69-
android:hint="@string/multi_reddit_description_hint"
70-
android:inputType="textMultiLine"
71-
android:textSize="?attr/font_default"
72-
android:background="#00000000"
73-
android:textColor="?attr/primaryTextColor"
74-
android:fontFamily="?attr/font_family" />
127+
app:chipSpacingHorizontal="16dp">
75128

76-
<View
77-
android:id="@+id/divider_2_create_multi_reddit_activity"
78-
android:layout_width="match_parent"
79-
android:layout_height="1dp"/>
129+
<com.google.android.material.chip.Chip
130+
android:id="@+id/select_subreddit_chip_create_multi_reddit_activity"
131+
android:layout_width="wrap_content"
132+
android:layout_height="wrap_content"
133+
android:text="@string/select_subreddits_and_users"
134+
android:textSize="?attr/font_default"
135+
android:fontFamily="?attr/font_family"
136+
style="@style/Widget.Material3.Chip.Assist" />
80137

81-
<LinearLayout
138+
<com.google.android.material.chip.Chip
139+
android:id="@+id/visibility_chip_create_multi_reddit_activity"
140+
android:layout_width="wrap_content"
141+
android:layout_height="wrap_content"
142+
android:text="@string/private_multi_reddit"
143+
android:textSize="?attr/font_default"
144+
android:fontFamily="?attr/font_family"
145+
android:checked="true"
146+
style="@style/Widget.Material3.Chip.Filter" />
147+
148+
</com.google.android.material.chip.ChipGroup>
149+
150+
<!--<LinearLayout
82151
android:id="@+id/visibility_wrapper_linear_layout_create_multi_reddit_activity"
83152
android:layout_width="match_parent"
84153
android:layout_height="wrap_content"
85-
android:padding="16dp"
154+
android:paddingStart="16dp"
155+
android:paddingEnd="16dp"
86156
android:clickable="true"
87157
android:focusable="true"
88158
android:background="?attr/selectableItemBackground">
@@ -94,10 +164,9 @@
94164
android:layout_weight="1"
95165
android:text="@string/private_multi_reddit"
96166
android:textSize="?attr/font_default"
97-
android:textColor="?attr/primaryTextColor"
98167
android:fontFamily="?attr/font_family" />
99168
100-
<Switch
169+
<com.google.android.material.materialswitch.MaterialSwitch
101170
android:id="@+id/visibility_switch_create_multi_reddit_activity"
102171
android:layout_width="wrap_content"
103172
android:layout_height="wrap_content"
@@ -112,11 +181,10 @@
112181
android:padding="16dp"
113182
android:text="@string/select_subreddits_and_users"
114183
android:textSize="?attr/font_default"
115-
android:textColor="?attr/primaryTextColor"
116184
android:fontFamily="?attr/font_family"
117185
android:clickable="true"
118186
android:focusable="true"
119-
android:background="?attr/selectableItemBackground" />
187+
android:background="?attr/selectableItemBackground" />-->
120188

121189
</LinearLayout>
122190

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@
736736
<string name="device_default">Device Default</string>
737737
<string name="set_by_battery_saver">Set by Battery Saver</string>
738738

739+
<string name="multi_reddit_name_explanation">The name should be unique.</string>
739740
<string name="multi_reddit_name_hint">Name (Max 50 Characters)</string>
740741
<string name="multi_reddit_description_hint">Description</string>
741742
<string name="private_multi_reddit">Private</string>

0 commit comments

Comments
 (0)