package ch.poole.ohfragmenttest;

import java.util.ArrayList;

import android.content.res.Configuration;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import ch.poole.openinghoursfragment.OnSaveListener;
import ch.poole.openinghoursfragment.OpeningHoursFragment;
import ch.poole.openinghoursfragment.ValueWithDescription;


public class Test extends AppCompatActivity implements OnSaveListener {
	final String LONG_TEST = "Mo[2] -2 days 10:00-12:00;24/7;week 4-40 PH+2days dawn-09:00;dawn-25:00/25;2010-2100/4 12:01-13:02, 14:00 , 10:00-(sunset+02:00) , 13:00+, 11:01-45:00/46, dawn-dusk, sunrise+ ; 12-16 closed \"ein test\" ; Mo, We 12:01-13:02 ; Apr-Sep 10:01-13:03, Dec 13:03-21:01";
	final String SHORT_TEST = "dawn+";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test);
		
		FragmentManager fm = getSupportFragmentManager();
		FragmentTransaction ft = fm.beginTransaction();
	    Fragment prev = fm.findFragmentByTag("fragment_openinghours");
	    if (prev != null) {
	        ft.remove(prev);
	    }
	    ft.commit();

	    ArrayList<ValueWithDescription> textValues = new ArrayList<>();
//	    ValueWithDescription yes = new ValueWithDescription("yes", "Yes");
//	    textValues.add(yes);
//	    ValueWithDescription no = new ValueWithDescription("no", "No");
//	    textValues.add(no);
//	    
//	    ValueWithDescription key = new ValueWithDescription("opening_hours", "Opening hours");
	    ValueWithDescription key = new ValueWithDescription("collection_times", "Collection times");
        OpeningHoursFragment openingHoursDialog 
        	= OpeningHoursFragment.newInstance(key,null,R.style.Theme_AppCompat_Light_Dialog_Alert, 5, true, null);
        openingHoursDialog.show(fm, "fragment_openinghours");
	}

	@Override
	public void save(String key, String openingHours) {
		Log.d("Test", "save got " + openingHours + " for key " + key);
		TestFragment.showDialog(this, openingHours);
	}
	
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        this.recreate();
    }
}

@@ -505,17 +505,16 @@
 ption;%0A%0A
-%0A
 public c
@@ -577,17 +577,20 @@
 tener %7B%0A
-%09
+    
 final St
@@ -604,16 +604,17 @@
 NG_TEST 
+ 
 = %22Mo%5B2%5D
@@ -873,17 +873,20 @@
 21:01%22;%0A
-%09
+    
 final St
@@ -912,19 +912,21 @@
 dawn+%22;%0A
-%09%0A%09
+%0A    
 @Overrid
@@ -927,17 +927,20 @@
 verride%0A
-%09
+    
 protecte
@@ -984,18 +984,24 @@
 tate) %7B%0A
-%09%09
+        
 super.on
@@ -1028,18 +1028,24 @@
 State);%0A
-%09%09
+        
 setConte
@@ -1080,13 +1080,17 @@
 t);%0A
-%09%09%0A%09%09
+%0A        
 Frag
@@ -1135,18 +1135,24 @@
 ager();%0A
-%09%09
+        
 Fragment
@@ -1191,17 +1191,20 @@
 tion();%0A
-%09
+    
     Frag
@@ -1258,25 +1258,28 @@
 inghours%22);%0A
-%09
+    
     if (prev
@@ -1290,17 +1290,20 @@
 null) %7B%0A
-%09
+    
         
@@ -1323,16 +1323,22 @@
 v);%0A
-%09
+    
     %7D%0A
-%09
+    
     
@@ -1351,17 +1351,20 @@
 mit();%0A%0A
-%09
+    
     Arra
@@ -1423,19 +1423,20 @@
 st%3C%3E();%0A
-//%09
+    
     Valu
@@ -1494,27 +1494,28 @@
 s%22, %22Yes%22);%0A
-//%09
+    
     textValu
@@ -1527,19 +1527,20 @@
 d(yes);%0A
-//%09
+    
     Valu
@@ -1599,19 +1599,20 @@
  %22No%22);%0A
-//%09
+    
     text
@@ -1631,22 +1631,19 @@
 o);%0A
-//%09
+%0A
     
-%0A//%09
+ 
    
+//
  Val
@@ -1726,17 +1726,20 @@
 ours%22);%0A
-%09
+    
     Valu
@@ -1879,18 +1879,8 @@
 log 
-%0A        %09
 = Op
@@ -1918,13 +1918,15 @@
 key,
+ 
 null,
+ 
 R.st
@@ -1974,20 +1974,26 @@
 , true, 
-null
+textValues
 );%0A     
@@ -2053,13 +2053,19 @@
 %22);%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 @Ove
@@ -2070,17 +2070,20 @@
 verride%0A
-%09
+    
 public v
@@ -2126,18 +2126,24 @@
 ours) %7B%0A
-%09%09
+        
 Log.d(%22T
@@ -2201,10 +2201,16 @@
 y);%0A
-%09%09
+        
 Test
@@ -2254,12 +2254,14 @@
 s);%0A
-%09
+    
 %7D%0A
-%09
 %0A   

Use mixed mode in test app