1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.aconfig.demo; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.util.Log; 22 import android.view.View; 23 import android.view.WindowManager; 24 import android.widget.TextView; 25 import android.text.method.ScrollingMovementMethod; 26 27 import com.example.android.aconfig.demo.flags.Flags; 28 29 import javax.inject.Inject; 30 31 32 /** 33 * A minimal "Hello, World!" application. 34 */ 35 public class AconfigDemoActivity extends Activity { 36 @Inject InjectedContent injectedContent; 37 /** 38 * Called with the activity is first created. 39 */ 40 @Override onCreate(Bundle savedInstanceState)41 public void onCreate(Bundle savedInstanceState) { 42 ((AconfigDemoApplication)getApplicationContext()).appComponent.inject(this); 43 super.onCreate(savedInstanceState); 44 45 setContentView(R.layout.main); 46 TextView simpleTextView = (TextView) findViewById(R.id.simpleTextView); 47 simpleTextView.setMovementMethod(new ScrollingMovementMethod()); 48 49 simpleTextView.setText("Show Java Flags: \n\n"); 50 51 StaticContent cp = new StaticContent(); 52 simpleTextView.append(cp.getContent()); 53 54 simpleTextView.append(injectedContent.getContent()); 55 56 simpleTextView.append("Show C/C++ Flags: \n\n"); 57 simpleTextView.append(printCFlag()); 58 59 if (Flags.awesomeFlag1()) { 60 Log.v("AconfigDemoActivity", Flags.FLAG_AWESOME_FLAG_1 + " is on!"); 61 } 62 63 if (Flags.awesomeFlag2()) { 64 Log.v("AconfigDemoActivity", Flags.FLAG_AWESOME_FLAG_2 + " is on!"); 65 } 66 67 simpleTextView.append("\n\nShow Rust Flags: \n\n"); 68 simpleTextView.append(printRustFlag()); 69 } 70 printCFlag()71 public native String printCFlag(); printRustFlag()72 public native String printRustFlag(); 73 74 static { 75 System.loadLibrary("example_cpp_lib"); 76 System.loadLibrary("example_rust_jni"); 77 } 78 } 79