From 108f7a42fe1ef0131618fc7d5d50dc8c0b7ead32 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Thu, 5 Oct 2023 20:42:54 +0300 Subject: [PATCH] disclaimer: refactor to fragment with navigation (fixes #2571) (#2573) Co-authored-by: dogi --- app/build.gradle | 4 ++-- app/src/main/AndroidManifest.xml | 3 --- .../ui/dashboard/DashboardActivity.java | 2 +- .../ui/dashboard/DisclaimerActivity.kt | 21 ----------------- .../ui/dashboard/DisclaimerFragment.kt | 23 +++++++++++++++++++ .../main/res/layout/fragment_disclaimer.xml | 14 +++++++++++ 6 files changed, 40 insertions(+), 27 deletions(-) delete mode 100644 app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerActivity.kt create mode 100644 app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerFragment.kt create mode 100644 app/src/main/res/layout/fragment_disclaimer.xml diff --git a/app/build.gradle b/app/build.gradle index 735345c54e..74d50b36c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1080 - versionName "0.10.80" + versionCode 1081 + versionName "0.10.81" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 63b78d880d..325094d19c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -54,9 +54,6 @@ android:name=".ui.news.NewsDetailActivity" android:label="@string/title_activity_news_detail" android:theme="@style/MyMaterialTheme.NoActionBar" /> - diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java index d1a97db12a..7b27ff95ea 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.java @@ -166,7 +166,7 @@ public boolean onMenuItemClick(MenuItem item) { startActivity(new Intent(DashboardActivity.this, SettingActivity.class)); break; case R.id.action_disclaimer: - startActivity(new Intent(DashboardActivity.this, DisclaimerActivity.class)); + openCallFragment(new DisclaimerFragment()); break; case R.id.action_about: openCallFragment(new AboutFragment()); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerActivity.kt deleted file mode 100644 index bbaf5934f9..0000000000 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerActivity.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.ole.planet.myplanet.ui.dashboard - -import android.os.Build -import android.os.Bundle -import android.text.Html -import androidx.annotation.RequiresApi -import androidx.core.text.HtmlCompat -import kotlinx.android.synthetic.main.activity_disclaimer.tv_disclaimer -import org.ole.planet.myplanet.R -import org.ole.planet.myplanet.base.BaseActivity -import org.ole.planet.myplanet.utilities.Constants - -class DisclaimerActivity : BaseActivity() { - @RequiresApi(Build.VERSION_CODES.N) - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_disclaimer) - initActionBar() - tv_disclaimer.text = Html.fromHtml(getString(Constants.DISCLAIMER), HtmlCompat.FROM_HTML_MODE_LEGACY) - } -} diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerFragment.kt new file mode 100644 index 0000000000..80d459ea02 --- /dev/null +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DisclaimerFragment.kt @@ -0,0 +1,23 @@ +package org.ole.planet.myplanet.ui.dashboard + +import android.os.Build +import android.os.Bundle +import android.text.Html +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.annotation.RequiresApi +import androidx.core.text.HtmlCompat +import androidx.fragment.app.Fragment +import org.ole.planet.myplanet.databinding.FragmentDisclaimerBinding +import org.ole.planet.myplanet.utilities.Constants + +class DisclaimerFragment : Fragment() { + private lateinit var fragmentDisclaimerBinding: FragmentDisclaimerBinding + @RequiresApi(Build.VERSION_CODES.N) + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + fragmentDisclaimerBinding = FragmentDisclaimerBinding.inflate(inflater, container, false) + fragmentDisclaimerBinding.tvDisclaimer.text = Html.fromHtml(getString(Constants.DISCLAIMER), HtmlCompat.FROM_HTML_MODE_LEGACY) + return fragmentDisclaimerBinding.root + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_disclaimer.xml b/app/src/main/res/layout/fragment_disclaimer.xml new file mode 100644 index 0000000000..ee046097e8 --- /dev/null +++ b/app/src/main/res/layout/fragment_disclaimer.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file