diff --git a/test-app/runtime/build.gradle b/test-app/runtime/build.gradle
index e55ba3bc6..7b02ad855 100644
--- a/test-app/runtime/build.gradle
+++ b/test-app/runtime/build.gradle
@@ -205,6 +205,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion"
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.navigation:navigation-ui-ktx:2.5.3'
+ implementation 'androidx.preference:preference:1.2.1'
}
diff --git a/test-app/runtime/src/debug/java/com/tns/ErrorReport.java b/test-app/runtime/src/debug/java/com/tns/ErrorReport.java
index d2b5cf2d6..3ded03ef2 100644
--- a/test-app/runtime/src/debug/java/com/tns/ErrorReport.java
+++ b/test-app/runtime/src/debug/java/com/tns/ErrorReport.java
@@ -32,9 +32,10 @@
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
-import androidx.fragment.app.FragmentStatePagerAdapter;
-import androidx.viewpager.widget.ViewPager;
+import androidx.viewpager2.widget.ViewPager2;
+import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
@@ -59,7 +60,7 @@ class ErrorReport implements TabLayout.OnTabSelectedListener {
private static AppCompatActivity activity;
private TabLayout tabLayout;
- private ViewPager viewPager;
+ private ViewPager2 viewPager;
private Context context;
private static String exceptionMsg;
@@ -279,12 +280,12 @@ void buildUI() {
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
int pagerId = this.context.getResources().getIdentifier("pager", "id", this.context.getPackageName());
- viewPager = (ViewPager) activity.findViewById(pagerId);
+ viewPager = (ViewPager2) activity.findViewById(pagerId);
- Pager adapter = new Pager(activity.getSupportFragmentManager(), tabLayout.getTabCount());
+ Pager adapter = new Pager(activity, tabLayout.getTabCount());
viewPager.setAdapter(adapter);
- viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
+ viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@@ -332,18 +333,18 @@ public void onTabReselected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
- private class Pager extends FragmentStatePagerAdapter {
+ private class Pager extends FragmentStateAdapter {
int tabCount;
@SuppressWarnings("deprecation")
- public Pager(FragmentManager fm, int tabCount) {
+ public Pager(FragmentActivity fm, int tabCount) {
super(fm);
this.tabCount = tabCount;
}
@Override
- public Fragment getItem(int position) {
+ public Fragment createFragment(int position) {
switch (position) {
case 0:
return new ExceptionTab();
@@ -355,7 +356,7 @@ public Fragment getItem(int position) {
}
@Override
- public int getCount() {
+ public int getItemCount() {
return tabCount;
}
}
@@ -410,14 +411,14 @@ public static void restartApp(Context context) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- int exceptionTabId = container.getContext().getResources().getIdentifier("exception_tab", "layout", container.getContext().getPackageName());
+ int exceptionTabId = getContext().getResources().getIdentifier("exception_tab", "layout", getContext().getPackageName());
View view = inflater.inflate(exceptionTabId, container, false);
int errorExceptionViewId = activity.getResources().getIdentifier("errorException", "id", activity.getPackageName());
TextView errorExceptionView = (TextView) activity.findViewById(errorExceptionViewId);
errorExceptionView.setMovementMethod(new ScrollingMovementMethod());
- int errorStackTraceViewId = container.getContext().getResources().getIdentifier("errorStacktrace", "id", container.getContext().getPackageName());
+ int errorStackTraceViewId = getContext().getResources().getIdentifier("errorStacktrace", "id", getContext().getPackageName());
TextView errorStackTraceView = (TextView) view.findViewById(errorStackTraceViewId);
String[] exceptionParts = exceptionMsg.split("StackTrace:");
@@ -438,10 +439,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
errorStackTraceView.setMovementMethod(LinkMovementMethod.getInstance());
errorStackTraceView.setEnabled(true);
- int btnCopyExceptionId = container.getContext().getResources().getIdentifier("btnCopyException", "id", container.getContext().getPackageName());
+ int btnCopyExceptionId = getContext().getResources().getIdentifier("btnCopyException", "id", getContext().getPackageName());
Button copyToClipboard = (Button) view.findViewById(btnCopyExceptionId);
- int btnRestartAppId = container.getContext().getResources().getIdentifier("btnRestartApp", "id", container.getContext().getPackageName());
+ int btnRestartAppId = getContext().getResources().getIdentifier("btnRestartApp", "id", getContext().getPackageName());
Button restartApp = (Button) view.findViewById(btnRestartAppId);
restartApp.setOnClickListener(v -> {
restartApp(getContext().getApplicationContext());
@@ -459,10 +460,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public static class LogcatTab extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- int logcatTabId = container.getContext().getResources().getIdentifier("logcat_tab", "layout", container.getContext().getPackageName());
+ int logcatTabId = getContext().getResources().getIdentifier("logcat_tab", "layout", getContext().getPackageName());
View view = inflater.inflate(logcatTabId, container, false);
- int textViewId = container.getContext().getResources().getIdentifier("logcatMsg", "id", container.getContext().getPackageName());
+ int textViewId = getContext().getResources().getIdentifier("logcatMsg", "id", getContext().getPackageName());
TextView txtlogcatMsg = (TextView) view.findViewById(textViewId);
txtlogcatMsg.setText(logcatMsg);
@@ -470,7 +471,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
final String logName = "Log-" + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
- int btnCopyLogcatId = container.getContext().getResources().getIdentifier("btnCopyLogcat", "id", container.getContext().getPackageName());
+ int btnCopyLogcatId = getContext().getResources().getIdentifier("btnCopyLogcat", "id", getContext().getPackageName());
Button copyToClipboard = (Button) view.findViewById(btnCopyLogcatId);
copyToClipboard.setOnClickListener(new View.OnClickListener() {
@Override
@@ -498,7 +499,7 @@ public void onClick(View v) {
} catch (Exception e) {
String err = "Could not write logcat report to sdcard. Make sure you have allowed access to external storage!";
Toast.makeText(activity, err, Toast.LENGTH_LONG).show();
- if (Util.isDebuggableApp(container.getContext())) {
+ if (Util.isDebuggableApp(getContext())) {
e.printStackTrace();
}
}
diff --git a/test-app/runtime/src/debug/res/layout/error_activity.xml b/test-app/runtime/src/debug/res/layout/error_activity.xml
index 9e614f6f3..dedf9f8f0 100644
--- a/test-app/runtime/src/debug/res/layout/error_activity.xml
+++ b/test-app/runtime/src/debug/res/layout/error_activity.xml
@@ -35,14 +35,14 @@
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" />
-
-
+
+ android:background="@drawable/button_accented"
+ android:foreground="?android:attr/selectableItemBackground"
+ android:text="Restart APP"
+ android:textAlignment="center"
+ android:textColor="@android:color/white" />
+ android:layout_weight="1"
+ android:background="@drawable/button"
+ android:foreground="?android:attr/selectableItemBackground"
+ android:text="Copy"
+ android:textAlignment="center"
+ android:textColor="@android:color/white" />
diff --git a/test-app/runtime/src/debug/res/layout/logcat_tab.xml b/test-app/runtime/src/debug/res/layout/logcat_tab.xml
index 4012d9bab..c3b44b344 100644
--- a/test-app/runtime/src/debug/res/layout/logcat_tab.xml
+++ b/test-app/runtime/src/debug/res/layout/logcat_tab.xml
@@ -21,18 +21,19 @@
diff --git a/test-app/runtime/src/main/java/com/tns/RuntimeHelper.java b/test-app/runtime/src/main/java/com/tns/RuntimeHelper.java
index 9d79bf3a6..c10b59b86 100644
--- a/test-app/runtime/src/main/java/com/tns/RuntimeHelper.java
+++ b/test-app/runtime/src/main/java/com/tns/RuntimeHelper.java
@@ -8,7 +8,7 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
-import android.preference.PreferenceManager;
+import androidx.preference.PreferenceManager;
import android.util.Log;
import java.io.File;
diff --git a/test-app/runtime/src/main/java/com/tns/Util.java b/test-app/runtime/src/main/java/com/tns/Util.java
index 74f5f1a8e..86ce6ccb6 100644
--- a/test-app/runtime/src/main/java/com/tns/Util.java
+++ b/test-app/runtime/src/main/java/com/tns/Util.java
@@ -56,7 +56,7 @@ static boolean runPlugin(Logger logger, Context context) {
try {
Class> liveSyncPluginClass = Class.forName(pluginClassName);
- Plugin p = (Plugin) liveSyncPluginClass.newInstance();
+ Plugin p = (Plugin) liveSyncPluginClass.getDeclaredConstructor().newInstance();
success = p.execute(context);
} catch (Exception e) {
if (Util.isDebuggableApp(context) && logger.isEnabled()) {