Skip to content

Commit 25d8275

Browse files
slavickmarc-medley
andauthored
v23 (#232)
* localization updates cs01-cs05: all languages with general updates for bg/fr/it (#230) * localization update v01-v04: all languages. fr, it, ro have larger general updates. * faq content * adds changeset v05 peanuts * fix markdown hyperlink syntax: es, pt-rBR, ru. add es hyperlink. * Add Frequently Asked Questions menu item * Replace large if with switch * Add FaqActivity * NF.org /book/ url update (#231) * Add link to How Not to Diet in AboutActivity * Add Markwon library to support Markdown links inside TextViews * Update versionCode and versionName --------- Co-authored-by: --marc <[email protected]>
1 parent 07a2678 commit 25d8275

File tree

25 files changed

+1356
-716
lines changed

25 files changed

+1356
-716
lines changed

app/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ android {
3434
multiDexEnabled true
3535
targetSdkVersion 33
3636
vectorDrawables.useSupportLibrary = true
37-
versionCode 83
38-
versionName "22.1"
37+
versionCode 84
38+
versionName "23"
3939
}
4040
buildTypes {
4141
debug {
@@ -74,4 +74,5 @@ dependencies {
7474
implementation('org.greenrobot:eventbus:3.2.0') { exclude group: "com.android.support" }
7575
implementation 'com.google.code.gson:gson:2.8.6'
7676
implementation 'com.jakewharton.timber:timber:4.7.1'
77+
implementation "io.noties.markwon:core:4.6.2"
7778
}

app/src/main/AndroidManifest.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@
139139
android:value=".activity.MainActivity"/>
140140
</activity>
141141

142+
<activity android:name=".activity.FaqActivity"
143+
android:label="@string/faq_title"
144+
android:screenOrientation="portrait"
145+
android:configChanges="orientation|keyboardHidden"
146+
android:parentActivityName=".activity.MainActivity">
147+
<meta-data
148+
android:name="android.support.PARENT_ACTIVITY"
149+
android:value=".activity.MainActivity"/>
150+
</activity>
151+
142152
<receiver
143153
android:name=".receiver.AlarmReceiver"
144154
android:process=":remote"/>

app/src/main/java/org/nutritionfacts/dailydozen/activity/AboutActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ private void initLinksInWelcome() {
6060
final SpannableStringBuilder ssb = new SpannableStringBuilder(welcomeText);
6161

6262
initLink(welcomeText, ssb, R.string.title_how_not_to_die, R.string.url_how_not_to_die);
63+
initLink(welcomeText, ssb, R.string.title_how_not_to_diet, R.string.url_how_not_to_diet);
6364

6465
binding.aboutWelcome.setMovementMethod(LinkMovementMethod.getInstance());
6566
binding.aboutWelcome.setText(ssb, TextView.BufferType.SPANNABLE);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.nutritionfacts.dailydozen.activity;
2+
3+
import android.os.Bundle;
4+
5+
import androidx.annotation.Nullable;
6+
import androidx.appcompat.app.AppCompatActivity;
7+
8+
import org.nutritionfacts.dailydozen.R;
9+
import org.nutritionfacts.dailydozen.databinding.ActivityFaqBinding;
10+
11+
import io.noties.markwon.Markwon;
12+
13+
public class FaqActivity extends AppCompatActivity {
14+
private ActivityFaqBinding binding;
15+
16+
@Override
17+
protected void onCreate(@Nullable Bundle savedInstanceState) {
18+
super.onCreate(savedInstanceState);
19+
binding = ActivityFaqBinding.inflate(getLayoutInflater());
20+
setContentView(binding.getRoot());
21+
init();
22+
}
23+
24+
private void init() {
25+
final Markwon markwon = Markwon.create(this);
26+
markwon.setMarkdown(binding.faqScalingResponse, getString(R.string.faq_scaling_response));
27+
markwon.setMarkdown(binding.faqSupplementsResponse, getString(R.string.faq_supplements_response));
28+
}
29+
}

app/src/main/java/org/nutritionfacts/dailydozen/activity/MainActivity.java

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -188,53 +188,57 @@ private void toggleTweaksMenuItemVisibility() {
188188
@Override
189189
public boolean onOptionsItemSelected(MenuItem item) {
190190
int itemId = item.getItemId();
191-
if (itemId == R.id.menu_toggle_modes) {
192-
inDailyDozenMode = !inDailyDozenMode;
193-
if (inDailyDozenMode) {
194-
setTitle(R.string.app_name);
195-
item.setTitle(R.string.twenty_one_tweaks);
196-
} else {
197-
setTitle(R.string.twenty_one_tweaks);
198-
item.setTitle(R.string.app_name);
199-
}
200-
initDatePager();
201-
return true;
202-
} else if (itemId == R.id.menu_latest_videos) {
203-
Common.openUrlInExternalBrowser(this, R.string.url_latest_videos);
204-
return true;
205-
} else if (itemId == R.id.menu_how_not_to_die) {
206-
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_die);
207-
return true;
208-
} else if (itemId == R.id.menu_cookbook) {
209-
Common.openUrlInExternalBrowser(this, R.string.url_cookbook);
210-
return true;
211-
} else if (itemId == R.id.menu_how_not_to_diet) {
212-
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_diet);
213-
return true;
214-
} else if (itemId == R.id.menu_daily_dozen_challenge) {
215-
Common.openUrlInExternalBrowser(this, R.string.url_daily_dozen_challenge);
216-
return true;
217-
} else if (itemId == R.id.menu_donate) {
218-
Common.openUrlInExternalBrowser(this, R.string.url_donate);
219-
return true;
220-
} else if (itemId == R.id.menu_subscribe) {
221-
Common.openUrlInExternalBrowser(this, R.string.url_subscribe);
222-
return true;
223-
} else if (itemId == R.id.menu_open_source) {
224-
Common.openUrlInExternalBrowser(this, R.string.url_open_source);
225-
return true;
226-
} else if (itemId == R.id.menu_daily_reminder_settings) {
227-
startActivity(new Intent(this, DailyReminderSettingsActivity.class));
228-
return true;
229-
} else if (itemId == R.id.menu_backup) {
230-
backup();
231-
return true;
232-
} else if (itemId == R.id.menu_about) {
233-
startActivity(new Intent(this, AboutActivity.class));
234-
return true;
235-
} else if (itemId == R.id.menu_debug) {
236-
startActivityForResult(new Intent(this, DebugActivity.class), Args.DEBUG_SETTINGS_REQUEST);
237-
return true;
191+
switch (itemId) {
192+
case R.id.menu_toggle_modes:
193+
inDailyDozenMode = !inDailyDozenMode;
194+
if (inDailyDozenMode) {
195+
setTitle(R.string.app_name);
196+
item.setTitle(R.string.twenty_one_tweaks);
197+
} else {
198+
setTitle(R.string.twenty_one_tweaks);
199+
item.setTitle(R.string.app_name);
200+
}
201+
initDatePager();
202+
return true;
203+
case R.id.menu_latest_videos:
204+
Common.openUrlInExternalBrowser(this, R.string.url_latest_videos);
205+
return true;
206+
case R.id.menu_how_not_to_die:
207+
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_die);
208+
return true;
209+
case R.id.menu_cookbook:
210+
Common.openUrlInExternalBrowser(this, R.string.url_cookbook);
211+
return true;
212+
case R.id.menu_how_not_to_diet:
213+
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_diet);
214+
return true;
215+
case R.id.menu_daily_dozen_challenge:
216+
Common.openUrlInExternalBrowser(this, R.string.url_daily_dozen_challenge);
217+
return true;
218+
case R.id.menu_faq:
219+
startActivity(new Intent(this, FaqActivity.class));
220+
return true;
221+
case R.id.menu_donate:
222+
Common.openUrlInExternalBrowser(this, R.string.url_donate);
223+
return true;
224+
case R.id.menu_subscribe:
225+
Common.openUrlInExternalBrowser(this, R.string.url_subscribe);
226+
return true;
227+
case R.id.menu_open_source:
228+
Common.openUrlInExternalBrowser(this, R.string.url_open_source);
229+
return true;
230+
case R.id.menu_daily_reminder_settings:
231+
startActivity(new Intent(this, DailyReminderSettingsActivity.class));
232+
return true;
233+
case R.id.menu_backup:
234+
backup();
235+
return true;
236+
case R.id.menu_about:
237+
startActivity(new Intent(this, AboutActivity.class));
238+
return true;
239+
case R.id.menu_debug:
240+
startActivityForResult(new Intent(this, DebugActivity.class), Args.DEBUG_SETTINGS_REQUEST);
241+
return true;
238242
}
239243
return super.onOptionsItemSelected(item);
240244
}
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
xmlns:app="http://schemas.android.com/apk/res-auto">
6+
7+
<LinearLayout
8+
android:layout_width="match_parent"
9+
android:layout_height="wrap_content"
10+
android:orientation="vertical">
11+
12+
<androidx.cardview.widget.CardView
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
android:layout_margin="10dp"
16+
app:cardElevation="6dp">
17+
18+
<LinearLayout
19+
style="@style/Widget.CardContent"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:orientation="vertical">
23+
24+
<TextView
25+
android:text="@string/faq_adapt_question"
26+
style="@style/PrimaryText"
27+
android:layout_marginBottom="20dp"
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content"/>
30+
31+
<TextView
32+
android:text="@string/faq_adapt_response"
33+
style="@style/SecondaryText"
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content"/>
36+
37+
</LinearLayout>
38+
39+
</androidx.cardview.widget.CardView>
40+
41+
<androidx.cardview.widget.CardView
42+
android:layout_width="match_parent"
43+
android:layout_height="wrap_content"
44+
android:layout_margin="10dp"
45+
app:cardElevation="6dp">
46+
47+
<LinearLayout
48+
style="@style/Widget.CardContent"
49+
android:layout_width="match_parent"
50+
android:layout_height="wrap_content"
51+
android:orientation="vertical">
52+
53+
<TextView
54+
android:text="@string/faq_age_question"
55+
style="@style/PrimaryText"
56+
android:layout_marginBottom="20dp"
57+
android:layout_width="match_parent"
58+
android:layout_height="wrap_content"/>
59+
60+
<TextView
61+
android:text="@string/faq_age_response.0"
62+
style="@style/SecondaryText"
63+
android:layout_marginBottom="20dp"
64+
android:layout_width="match_parent"
65+
android:layout_height="wrap_content"/>
66+
67+
<TextView
68+
android:text="@string/faq_age_response.1"
69+
style="@style/SecondaryText"
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content"/>
72+
73+
</LinearLayout>
74+
75+
</androidx.cardview.widget.CardView>
76+
77+
<androidx.cardview.widget.CardView
78+
android:layout_width="match_parent"
79+
android:layout_height="wrap_content"
80+
android:layout_margin="10dp"
81+
app:cardElevation="6dp">
82+
83+
<LinearLayout
84+
style="@style/Widget.CardContent"
85+
android:layout_width="match_parent"
86+
android:layout_height="wrap_content"
87+
android:orientation="vertical">
88+
89+
<TextView
90+
android:text="@string/faq_calories_question"
91+
style="@style/PrimaryText"
92+
android:layout_marginBottom="20dp"
93+
android:layout_width="match_parent"
94+
android:layout_height="wrap_content"/>
95+
96+
<TextView
97+
android:text="@string/faq_calories_response.0"
98+
style="@style/SecondaryText"
99+
android:layout_marginBottom="20dp"
100+
android:layout_width="match_parent"
101+
android:layout_height="wrap_content"/>
102+
103+
<TextView
104+
android:text="@string/faq_calories_response.1"
105+
style="@style/SecondaryText"
106+
android:layout_marginBottom="20dp"
107+
android:layout_width="match_parent"
108+
android:layout_height="wrap_content"/>
109+
110+
<TextView
111+
android:text="@string/faq_calories_response.2"
112+
style="@style/SecondaryText"
113+
android:layout_width="match_parent"
114+
android:layout_height="wrap_content"/>
115+
116+
</LinearLayout>
117+
118+
</androidx.cardview.widget.CardView>
119+
120+
<androidx.cardview.widget.CardView
121+
android:layout_width="match_parent"
122+
android:layout_height="wrap_content"
123+
android:layout_margin="10dp"
124+
app:cardElevation="6dp">
125+
126+
<LinearLayout
127+
style="@style/Widget.CardContent"
128+
android:layout_width="match_parent"
129+
android:layout_height="wrap_content"
130+
android:orientation="vertical">
131+
132+
<TextView
133+
android:text="@string/faq_mother_question"
134+
style="@style/PrimaryText"
135+
android:layout_marginBottom="20dp"
136+
android:layout_width="match_parent"
137+
android:layout_height="wrap_content"/>
138+
139+
<TextView
140+
android:text="@string/faq_mother_response"
141+
style="@style/SecondaryText"
142+
android:layout_width="match_parent"
143+
android:layout_height="wrap_content"/>
144+
145+
</LinearLayout>
146+
147+
</androidx.cardview.widget.CardView>
148+
149+
<androidx.cardview.widget.CardView
150+
android:layout_width="match_parent"
151+
android:layout_height="wrap_content"
152+
android:layout_margin="10dp"
153+
app:cardElevation="6dp">
154+
155+
<LinearLayout
156+
style="@style/Widget.CardContent"
157+
android:layout_width="match_parent"
158+
android:layout_height="wrap_content"
159+
android:orientation="vertical">
160+
161+
<TextView
162+
android:text="@string/faq_scaling_question"
163+
style="@style/PrimaryText"
164+
android:layout_marginBottom="20dp"
165+
android:layout_width="match_parent"
166+
android:layout_height="wrap_content"/>
167+
168+
<TextView
169+
android:id="@+id/faq_scaling_response"
170+
android:text="@string/faq_scaling_response"
171+
style="@style/SecondaryText"
172+
android:layout_width="match_parent"
173+
android:layout_height="wrap_content"/>
174+
175+
</LinearLayout>
176+
177+
</androidx.cardview.widget.CardView>
178+
179+
<androidx.cardview.widget.CardView
180+
android:layout_width="match_parent"
181+
android:layout_height="wrap_content"
182+
android:layout_margin="10dp"
183+
app:cardElevation="6dp">
184+
185+
<LinearLayout
186+
style="@style/Widget.CardContent"
187+
android:layout_width="match_parent"
188+
android:layout_height="wrap_content"
189+
android:orientation="vertical">
190+
191+
<TextView
192+
android:text="@string/faq_supplements_question"
193+
style="@style/PrimaryText"
194+
android:layout_marginBottom="20dp"
195+
android:layout_width="match_parent"
196+
android:layout_height="wrap_content"/>
197+
198+
<TextView
199+
android:id="@+id/faq_supplements_response"
200+
android:text="@string/faq_supplements_response"
201+
style="@style/SecondaryText"
202+
android:layout_width="match_parent"
203+
android:layout_height="wrap_content"/>
204+
205+
</LinearLayout>
206+
207+
</androidx.cardview.widget.CardView>
208+
209+
</LinearLayout>
210+
211+
</ScrollView>

0 commit comments

Comments
 (0)