package jp.hazuki.yuzubrowser.debug;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ListFragment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import jp.hazuki.yuzubrowser.R;
import jp.hazuki.yuzubrowser.action.view.ActionStringActivity;

public class DebugActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_base);
        setTitle("Debug mode");

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, new ItemFragment())
                .commit();
    }


    public static class ItemFragment extends ListFragment {
        @Override
        public void onActivityCreated(@Nullable Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            String[] list = {"file list", "activity list", "action json string", "action list json string", "environment"};
            ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, list);
            setListAdapter(adapter);
        }

        @Override
        public void onListItemClick(ListView l, View v, int position, long id) {
            super.onListItemClick(l, v, position, id);
            switch (position) {
                case 0:
                    startActivity(new Intent(getActivity(), DebugFileListActivity.class));
                    break;
                case 1:
                    startActivity(new Intent(getActivity(), ActivityListActivity.class));
                    break;
                case 2: {
                    Intent intent = new Intent(getActivity(), ActionStringActivity.class);
                    intent.putExtra(ActionStringActivity.EXTRA_ACTIVITY, ActionStringActivity.ACTION_ACTIVITY);
                    startActivity(intent);
                }
                break;
                case 3: {
                    Intent intent = new Intent(getActivity(), ActionStringActivity.class);
                    intent.putExtra(ActionStringActivity.EXTRA_ACTIVITY, ActionStringActivity.ACTION_LIST_ACTIVITY);
                    startActivity(intent);
                }
                break;
                case 4:
                    startActivity(new Intent(getActivity(), EnvironmentActivity.class));
                    break;
            }
        }
    }
}

@@ -1,8 +1,603 @@
+/*%0A * Copyright (C) 2017 Hazuki%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0A
 package 
@@ -914,16 +914,87 @@
 stView;%0A
+import android.widget.Toast;%0A%0Aimport jp.hazuki.yuzubrowser.BuildConfig;
 %0Aimport 
@@ -2341,16 +2341,63 @@
 case 1:%0A
+                    if (BuildConfig.DEBUG)%0A    
         
@@ -2470,32 +2470,186 @@
 tivity.class));%0A
+                    else%0A                        Toast.makeText(getActivity(), %22This feature is only valid for debug builds%22, Toast.LENGTH_SHORT).show();%0A
                 

change debug activity