From 6c4cce00be6e782f6f636f1b224aabf44af9fc96 Mon Sep 17 00:00:00 2001 From: Adam Howard Date: Sun, 9 Jun 2019 23:13:23 +0100 Subject: [PATCH] fix(PalmCalcActivity): use androidx everywhere where possible this fixes crash caused by theme in manifest (cherry picked from commit 02a7e6920fc9fded1f944c56dcc056ef31c2668b) --- .../palmcalc/PalmCalcActivity.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/github/palmcalc2019/palmcalc/PalmCalcActivity.java b/app/src/main/java/com/github/palmcalc2019/palmcalc/PalmCalcActivity.java index 69383e2..e9abfc7 100644 --- a/app/src/main/java/com/github/palmcalc2019/palmcalc/PalmCalcActivity.java +++ b/app/src/main/java/com/github/palmcalc2019/palmcalc/PalmCalcActivity.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (C) <2013> * @@ -30,12 +30,28 @@ import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; + +//import com.actionbarsherlock.app.ActionBar; +import androidx.appcompat.app.ActionBar; +//import com.actionbarsherlock.app.SherlockFragmentActivity; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; +//import androidx.appcompat.app.AppCompatActivity; +//import com.actionbarsherlock.app.ActionBar.Tab; +import androidx.appcompat.app.ActionBar.Tab; +//import com.actionbarsherlock.view.Menu; +import android.view.Menu; +//import com.actionbarsherlock.view.MenuInflater; +import android.view.MenuInflater; +//import com.actionbarsherlock.view.MenuItem; +import android.view.MenuItem; + import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentStatePagerAdapter; -import android.app.FragmentTransaction; +import androidx.fragment.app.FragmentTransaction; import androidx.viewpager.widget.ViewPager; + import android.util.DisplayMetrics; -import android.view.MenuItem; import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -44,11 +60,6 @@ import android.widget.TextView; import android.widget.Toast; -import android.app.ActionBar; -import androidx.fragment.app.FragmentActivity; -import android.app.ActionBar.Tab; -import android.view.Menu; -import android.view.MenuInflater; import com.github.palmcalc2019.bmi.bmiactivity; import com.github.palmcalc2019.clock.GlobalClockActivity; import com.github.palmcalc2019.scientific.ScientificActivity; @@ -76,7 +87,7 @@ * this program. If not, see . **/ -public class PalmCalcActivity extends FragmentActivity implements +public class PalmCalcActivity extends AppCompatActivity implements android.view.View.OnClickListener { Button btnClear, btnSend; @@ -132,7 +143,7 @@ public void init() { mViewPager.setId(R.id.pager); showUserSettings(); setContentView(mViewPager); - bar = getActionBar();//getSupportActionBar(); + bar = getSupportActionBar(); getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); @@ -362,11 +373,11 @@ static final class TabInfo { } } - public TabsAdapter(FragmentActivity activity, ViewPager pager) { + public TabsAdapter(AppCompatActivity activity, ViewPager pager) { super(activity.getSupportFragmentManager()); mContext = activity; - mActionBar = activity.getActionBar(); + mActionBar = activity.getSupportActionBar(); mViewPager = pager; mViewPager.setAdapter(this); mViewPager.setOnPageChangeListener(this);