From 59cc96c16167a75a8c6409457c6736acb3a734e6 Mon Sep 17 00:00:00 2001 From: angrezichatterbox Date: Tue, 3 Sep 2024 15:56:14 +0530 Subject: [PATCH 1/2] feat:Implemented back button in the action bar --- app/build.gradle | 3 +- app/src/main/AndroidManifest.xml | 24 +---- .../java/be/scri/activities/MainActivity.kt | 94 +++++++++++++++++-- .../main/java/be/scri/extensions/Activity.kt | 2 +- .../java/be/scri/fragments/AboutFragment.kt | 4 +- .../fragments/LanguageSettingsFragment.kt | 25 ++++- .../java/be/scri/fragments/MainFragment.kt | 2 + .../scri/fragments/PrivacyPolicyFragment.kt | 23 ++++- .../be/scri/fragments/SettingsFragment.kt | 10 +- .../be/scri/fragments/ThirdPartyFragment.kt | 12 ++- .../scri/fragments/WikimediaScribeFragment.kt | 10 +- app/src/main/res/drawable/chevron.xml | 11 +++ .../main/res/drawable/ic_group_circle_bg.xml | 2 +- app/src/main/res/layout/activity_main.xml | 19 ++-- .../res/layout/custom_action_bar_layout.xml | 39 ++++++++ app/src/main/res/layout/fragment_about.xml | 2 +- .../res/layout/fragment_privacy_policy.xml | 2 +- app/src/main/res/layout/fragment_settings.xml | 13 +-- .../main/res/layout/fragment_third_party.xml | 2 +- .../res/layout/fragment_wikimedia_scribe.xml | 6 +- app/src/main/res/values-night-v31/colors.xml | 2 +- app/src/main/res/values-v31/colors.xml | 2 +- app/src/main/res/values/colors.xml | 6 +- 23 files changed, 241 insertions(+), 74 deletions(-) create mode 100644 app/src/main/res/drawable/chevron.xml create mode 100644 app/src/main/res/layout/custom_action_bar_layout.xml diff --git a/app/build.gradle b/app/build.gradle index 526879ab..efa0d848 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -88,7 +88,8 @@ dependencies { implementation 'com.google.android.material:material:1.12.0' implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.cardview:cardview:1.0.0' - implementation "androidx.viewpager2:viewpager2:1.0.0" + implementation "androidx.viewpager2:viewpager2:1.1.0" + api 'joda-time:joda-time:2.10.13' api 'com.github.tibbi:RecyclerView-FastScroller:e7d3e150c4' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e579c40f..3b4573a6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ android:localeConfig="@xml/locales_config" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme.Base"> @@ -31,7 +31,7 @@ + /> - - - - - diff --git a/app/src/main/java/be/scri/activities/MainActivity.kt b/app/src/main/java/be/scri/activities/MainActivity.kt index fe1b8026..25a49765 100644 --- a/app/src/main/java/be/scri/activities/MainActivity.kt +++ b/app/src/main/java/be/scri/activities/MainActivity.kt @@ -1,12 +1,17 @@ package be.scri.activities + import android.os.Bundle import android.view.View +import android.view.ViewGroup +import android.widget.Button +import android.widget.TextView import androidx.viewpager2.widget.ViewPager2 -import com.google.android.material.bottomnavigation.BottomNavigationView import be.scri.R import be.scri.adapters.ViewPagerAdapter import be.scri.databinding.ActivityMainBinding +import com.google.android.material.bottomnavigation.BottomNavigationView + class MainActivity : SimpleActivity() { @@ -17,9 +22,24 @@ class MainActivity : SimpleActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + supportActionBar?.displayOptions = androidx.appcompat.app.ActionBar.DISPLAY_SHOW_CUSTOM; + supportActionBar?.setDisplayShowCustomEnabled(true); + supportActionBar?.setCustomView(R.layout.custom_action_bar_layout); + supportActionBar?.elevation = 0F + val layoutParams = supportActionBar?.customView?.layoutParams + layoutParams?.height = 1000 + supportActionBar?.customView?.layoutParams = layoutParams + setActionBarTitle(R.string.app_launcher_name) + val mButton = supportActionBar?.customView?.findViewById