[Android] I want to make QA easier ... That's right! Let's make a debug menu!

What is a debug menu?

Hidden features for software developers. Since it is a function for developers only, it is standard that general users cannot operate it.

Do you need it?

It's not a mast. It's just to make debugging easier, so let's start by hearing from the person who debugs. However, if there is a voice saying that it would be nice to have it, or if debugging requires man-hours for engineers, it is better to make it.

Implemented function example

View & copy

action

Implementation example

This is an item cell sample. I think it's okay for parents to enclose it in ScrollView and multiply it.

activity_debug_menu.xml


<!--abridgement-->

                <!--Item Parent Name display&copy-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/listview_height"
                android:background="@color/debug_item_parent_color"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="@dimen/listview_margin_left"
                    android:gravity="left"
                    android:text="display&copy"
                    android:textColor="@color/debug_text_color"
                    android:textSize="14sp"/>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/white"
                android:orientation="vertical">

                <!-- Item Child Name Build Ver. -->
                <LinearLayout
                    android:id="@+id/build_info_area"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/listview_height"
                    android:layout_gravity="center"
                    android:background="@drawable/default_selector"
                    android:clickable="true"
                    android:orientation="horizontal"
                    android:paddingLeft="@dimen/listview_margin_left">

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent">

                        <ImageView
                            android:layout_width="@dimen/listview_icon_width"
                            android:layout_height="@dimen/listview_icon_height"
                            android:layout_gravity="center"
                            android:layout_marginRight="@dimen/listview_icon_margin_right"
                            android:background="@drawable/ic_build_36dp"/>

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="125dp"
                        android:layout_height="match_parent">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_gravity="center"
                            android:layout_marginRight="10dp"
                            android:gravity="center"
                            android:text="BUILD Ver."
                            android:textSize="@dimen/listview_item_text_size"/>

                    </LinearLayout>

                <!--Acquisition Ver-->
                    <TextView
                        android:id="@+id/build_info_txt"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="left|center"
                        android:text="Ver.X.XX.X"
                        android:textColor="@color/debug_text_color"
                        android:textSize="@dimen/listview_item_text_size"/>

                </LinearLayout>

                <!--Separator-->
                <include layout="@layout/component_divider_wrap"/>

<!--abridgement-->

It's just a dividing line.

component_divider_wrap.xml


<merge xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/div"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="72dp"
        android:layout_weight="1">

        <View style="@style/divider_horizontal"/>

    </LinearLayout>
</merge>

An example is described in onCreate as a sample, but it becomes difficult to read as the number of items increases, so it may be good to bind items with Butter Knife.

DebugMenuActivity.java


public class DebugMenuActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_debug_menu);
        
        // Build Ver. Text
        TextView buildInfoTxt = (TextView)findViewById(R.id.build_info_txt);
        
        buildInfoTxt.setText("Ver. " + BuildConfig.VERSION_NAME + " " + BuildConfig.BUILD_TIMESTAMP + " " + BuildConfig.BUILD_HASH + " (" + BuildConfig.BUILD_MACHINE + ")");
        // Build Ver. Area
    LinearLayout buildInfoArea =(LinearLayout)findViewById(R.id.build_info_area);
        
        buildInfoArea.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                copyClipBoard((String)buildInfoTxt.getText());
            }
        });
    }

   //Copy to clipboard
   private void copyClipBoard(String copySource) {
        if (copySource.equals("")) {
            return;
        }
 
        //Create an Item to store in the clipboard
        ClipData.Item item = new ClipData.Item(copySource);

        //Creating a MIME TYPE
        String[] mimeType = new String[1];
        mimeType[0] = ClipDescription.MIMETYPE_TEXT_URILIST;

        //Creating a ClipData object to store in the clipboard
        ClipData cd = new ClipData(new ClipDescription("text_data", mimeType), item);

        //Store data in clipboard
        ClipboardManager cm = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
        cm.setPrimaryClip(cd);
    }
}

See below

If you add a function that gives a suggestion when you tap the icon when changing the Host Name with self-satisfaction, it is surprisingly popular, or if you implement it because it is better to be able to authenticate external access, Pl will ** give me yakiniku Was ** ** Athlete engineers who like yakiniku! Let's make it: sunglasses: **

December 23rd is @ yuzu_afro's turn!

Recommended Posts

[Android] I want to make QA easier ... That's right! Let's make a debug menu!
[Introduction to Android application development] Let's make a counter
I want to make a specific model of ActiveRecord ReadOnly
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
I want to make a button with a line break with link_to [Note]
I want to develop a web application!
I tried to make a simple face recognition Android application using OpenCV
I want to write a unit test!
[Java] I want to make it easier because it is troublesome to input System.out.println.
Let's create a TODO application in Java 2 I want to create a template with Spring Initializr and make a Hello world
[Android] I want to create a ViewPager that can be used for tutorials
Rails6 I want to make an array of values with a check box
[Android] I tried to make a material list screen with ListView + Bottom Sheet
I did Java to make (a == 1 && a == 2 && a == 3) always true
[Ruby] I want to do a method jump!
I wanted to make (a == 1 && a == 2 && a == 3) true in Java
I want to design a structured exception handling
[Ruby] I want to make a program that displays today's day of the week!
I tried to make a simple game with Javafx ① "Let's find happiness game" (unfinished version ②)
I want to use a little icon in Rails
I tried to make a login function in Java
I want to define a function in Rails Console
[Android Studio] I want to use Maven library on Android
I want to add a reference type column later
I want to simplify the log output on Android
I want to connect to Heroku MySQL from a client
I want to create a generic annotation for a type
I want to add a delete function to the comment function
I tried adding a separator line to TabLayout on Android
[Java] I want to convert a byte array to a hexadecimal number
I want to find a relative path in a situation using Path
I want to call a method and count the number
I just wanted to make a Reactive Property in Java
I tried using Hotwire to make Rails 6.1 scaffold a SPA
I want to create a form to select the [Rails] category
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I want to give a class name to the select attribute
I want to create a Parquet file even in Ruby
I tried to make a client of RESAS-API in Java
I want to use FireBase to display a timeline like Twitter