Skip to content

Commit

Permalink
v23 (#232)
Browse files Browse the repository at this point in the history
* 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 <marc-medley@users.noreply.github.com>
  • Loading branch information
slavick and marc-medley committed Jun 19, 2023
1 parent 07a2678 commit 25d8275
Show file tree
Hide file tree
Showing 25 changed files with 1,356 additions and 716 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ android {
multiDexEnabled true
targetSdkVersion 33
vectorDrawables.useSupportLibrary = true
versionCode 83
versionName "22.1"
versionCode 84
versionName "23"
}
buildTypes {
debug {
Expand Down Expand Up @@ -74,4 +74,5 @@ dependencies {
implementation('org.greenrobot:eventbus:3.2.0') { exclude group: "com.android.support" }
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation "io.noties.markwon:core:4.6.2"
}
10 changes: 10 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@
android:value=".activity.MainActivity"/>
</activity>

<activity android:name=".activity.FaqActivity"
android:label="@string/faq_title"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:parentActivityName=".activity.MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.MainActivity"/>
</activity>

<receiver
android:name=".receiver.AlarmReceiver"
android:process=":remote"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private void initLinksInWelcome() {
final SpannableStringBuilder ssb = new SpannableStringBuilder(welcomeText);

initLink(welcomeText, ssb, R.string.title_how_not_to_die, R.string.url_how_not_to_die);
initLink(welcomeText, ssb, R.string.title_how_not_to_diet, R.string.url_how_not_to_diet);

binding.aboutWelcome.setMovementMethod(LinkMovementMethod.getInstance());
binding.aboutWelcome.setText(ssb, TextView.BufferType.SPANNABLE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.nutritionfacts.dailydozen.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import org.nutritionfacts.dailydozen.R;
import org.nutritionfacts.dailydozen.databinding.ActivityFaqBinding;

import io.noties.markwon.Markwon;

public class FaqActivity extends AppCompatActivity {
private ActivityFaqBinding binding;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityFaqBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
init();
}

private void init() {
final Markwon markwon = Markwon.create(this);
markwon.setMarkdown(binding.faqScalingResponse, getString(R.string.faq_scaling_response));
markwon.setMarkdown(binding.faqSupplementsResponse, getString(R.string.faq_supplements_response));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,53 +188,57 @@ private void toggleTweaksMenuItemVisibility() {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_toggle_modes) {
inDailyDozenMode = !inDailyDozenMode;
if (inDailyDozenMode) {
setTitle(R.string.app_name);
item.setTitle(R.string.twenty_one_tweaks);
} else {
setTitle(R.string.twenty_one_tweaks);
item.setTitle(R.string.app_name);
}
initDatePager();
return true;
} else if (itemId == R.id.menu_latest_videos) {
Common.openUrlInExternalBrowser(this, R.string.url_latest_videos);
return true;
} else if (itemId == R.id.menu_how_not_to_die) {
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_die);
return true;
} else if (itemId == R.id.menu_cookbook) {
Common.openUrlInExternalBrowser(this, R.string.url_cookbook);
return true;
} else if (itemId == R.id.menu_how_not_to_diet) {
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_diet);
return true;
} else if (itemId == R.id.menu_daily_dozen_challenge) {
Common.openUrlInExternalBrowser(this, R.string.url_daily_dozen_challenge);
return true;
} else if (itemId == R.id.menu_donate) {
Common.openUrlInExternalBrowser(this, R.string.url_donate);
return true;
} else if (itemId == R.id.menu_subscribe) {
Common.openUrlInExternalBrowser(this, R.string.url_subscribe);
return true;
} else if (itemId == R.id.menu_open_source) {
Common.openUrlInExternalBrowser(this, R.string.url_open_source);
return true;
} else if (itemId == R.id.menu_daily_reminder_settings) {
startActivity(new Intent(this, DailyReminderSettingsActivity.class));
return true;
} else if (itemId == R.id.menu_backup) {
backup();
return true;
} else if (itemId == R.id.menu_about) {
startActivity(new Intent(this, AboutActivity.class));
return true;
} else if (itemId == R.id.menu_debug) {
startActivityForResult(new Intent(this, DebugActivity.class), Args.DEBUG_SETTINGS_REQUEST);
return true;
switch (itemId) {
case R.id.menu_toggle_modes:
inDailyDozenMode = !inDailyDozenMode;
if (inDailyDozenMode) {
setTitle(R.string.app_name);
item.setTitle(R.string.twenty_one_tweaks);
} else {
setTitle(R.string.twenty_one_tweaks);
item.setTitle(R.string.app_name);
}
initDatePager();
return true;
case R.id.menu_latest_videos:
Common.openUrlInExternalBrowser(this, R.string.url_latest_videos);
return true;
case R.id.menu_how_not_to_die:
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_die);
return true;
case R.id.menu_cookbook:
Common.openUrlInExternalBrowser(this, R.string.url_cookbook);
return true;
case R.id.menu_how_not_to_diet:
Common.openUrlInExternalBrowser(this, R.string.url_how_not_to_diet);
return true;
case R.id.menu_daily_dozen_challenge:
Common.openUrlInExternalBrowser(this, R.string.url_daily_dozen_challenge);
return true;
case R.id.menu_faq:
startActivity(new Intent(this, FaqActivity.class));
return true;
case R.id.menu_donate:
Common.openUrlInExternalBrowser(this, R.string.url_donate);
return true;
case R.id.menu_subscribe:
Common.openUrlInExternalBrowser(this, R.string.url_subscribe);
return true;
case R.id.menu_open_source:
Common.openUrlInExternalBrowser(this, R.string.url_open_source);
return true;
case R.id.menu_daily_reminder_settings:
startActivity(new Intent(this, DailyReminderSettingsActivity.class));
return true;
case R.id.menu_backup:
backup();
return true;
case R.id.menu_about:
startActivity(new Intent(this, AboutActivity.class));
return true;
case R.id.menu_debug:
startActivityForResult(new Intent(this, DebugActivity.class), Args.DEBUG_SETTINGS_REQUEST);
return true;
}
return super.onOptionsItemSelected(item);
}
Expand Down
211 changes: 211 additions & 0 deletions app/src/main/res/layout/activity_faq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:text="@string/faq_adapt_question"
style="@style/PrimaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_adapt_response"
style="@style/SecondaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:text="@string/faq_age_question"
style="@style/PrimaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_age_response.0"
style="@style/SecondaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_age_response.1"
style="@style/SecondaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:text="@string/faq_calories_question"
style="@style/PrimaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_calories_response.0"
style="@style/SecondaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_calories_response.1"
style="@style/SecondaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_calories_response.2"
style="@style/SecondaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:text="@string/faq_mother_question"
style="@style/PrimaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:text="@string/faq_mother_response"
style="@style/SecondaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:text="@string/faq_scaling_question"
style="@style/PrimaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/faq_scaling_response"
android:text="@string/faq_scaling_response"
style="@style/SecondaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">

<LinearLayout
style="@style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:text="@string/faq_supplements_question"
style="@style/PrimaryText"
android:layout_marginBottom="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/faq_supplements_response"
android:text="@string/faq_supplements_response"
style="@style/SecondaryText"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>

</androidx.cardview.widget.CardView>

</LinearLayout>

</ScrollView>
Loading

0 comments on commit 25d8275

Please sign in to comment.