diff --git a/app-catalog/samples/foundation/src/main/AndroidManifest.xml b/app-catalog/samples/foundation/src/main/AndroidManifest.xml index 42cf878..eec4100 100644 --- a/app-catalog/samples/foundation/src/main/AndroidManifest.xml +++ b/app-catalog/samples/foundation/src/main/AndroidManifest.xml @@ -19,6 +19,8 @@ + + @@ -226,6 +228,80 @@ android:exported="true" android:theme="@style/Theme.AppCompat.DayNight" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --> - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app-catalog/samples/foundation/src/main/java/com/wintmain/foundation/prejob/extDemo/ContactListAdapter.java b/app-catalog/samples/foundation/src/main/java/com/wintmain/foundation/prejob/extDemo/ContactListAdapter.java deleted file mode 100644 index 08ae119..0000000 --- a/app-catalog/samples/foundation/src/main/java/com/wintmain/foundation/prejob/extDemo/ContactListAdapter.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2023-2024 wintmain - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.wintmain.foundation.prejob.extDemo; - -import android.content.ContentResolver; -import android.content.Context; -import android.database.Cursor; -import android.net.Uri; -import android.provider.ContactsContract; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.CursorAdapter; -import android.widget.FilterQueryProvider; -import android.widget.Filterable; -import android.widget.TextView; - -public class ContactListAdapter extends CursorAdapter implements Filterable { - private ContentResolver resolver; - private String[] columns = - new String[]{ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME}; - - public ContactListAdapter(Context context, Cursor c) { - super(context, c); // 调用父类构造方法 - resolver = context.getContentResolver(); // 初始化 - } - - @Override - public CharSequence convertToString(Cursor cursor) { - return cursor.getString(1); - } - - @Override - public Cursor runQueryOnBackgroundThread(CharSequence constraint) { - FilterQueryProvider filter = getFilterQueryProvider(); - if (filter != null) { - return filter.runQuery(constraint); - } - Uri uri = - Uri.withAppendedPath( - ContactsContract.Contacts.CONTENT_FILTER_URI, - Uri.encode(constraint.toString())); - return resolver.query(uri, columns, null, null, null); - } - - @Override - public View newView(Context context, Cursor cursor, ViewGroup viewGroup) { - LayoutInflater inflater = LayoutInflater.from(context); - TextView view = - (TextView) - inflater.inflate( - android.R.layout.simple_dropdown_item_1line, viewGroup, false); - view.setText(cursor.getString(1)); - return view; - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - ((TextView) view).setText(cursor.getString(1)); - } -} diff --git a/app-catalog/samples/foundation/src/main/java/com/wintmain/foundation/prejob/extDemo/Ep4_Intent.kt b/app-catalog/samples/foundation/src/main/java/com/wintmain/foundation/prejob/extDemo/Ep4_Intent.kt new file mode 100644 index 0000000..aa12df7 --- /dev/null +++ b/app-catalog/samples/foundation/src/main/java/com/wintmain/foundation/prejob/extDemo/Ep4_Intent.kt @@ -0,0 +1,232 @@ +/* + * Copyright 2023-2024 wintmain + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.wintmain.foundation.prejob.extDemo + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.widget.Button +import android.widget.EditText +import android.widget.LinearLayout +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import com.google.android.catalog.framework.annotations.Sample +import com.wintmain.foundation.R + +@Sample(name = "Intent", description = "意图示例", tags = ["A-Self_demos"]) +class ep4_1 : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.ep4_1) + if (supportActionBar != null) { + supportActionBar!!.setDisplayHomeAsUpEnabled(true) // 显示返回箭头 + supportActionBar!!.setHomeButtonEnabled(true) // 设置返回键可点击 + } + + val ok = findViewById