Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app-catalog/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ android {
applicationId "com.wintmain.catalog.app"
minSdk 26
targetSdk 34
versionCode 20241009
versionName 'V20241009'
versionCode 20241020
versionName 'V20241020'

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
32 changes: 4 additions & 28 deletions app-catalog/samples/foundation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,18 @@ android {
}

dependencies {
// implementation fileTree(include: ['*.jar', "*.aar"], dir: "libs")
implementation project(path: ':app-catalog:samples:xpermissions:libxpermissions')
implementation project(path: ':app-catalog:samples:foundation:libfoundation')
implementation project(path: ':app-catalog:samples:toaster:libtoaster')
implementation project(path: ':app-catalog:samples:titlebar:libtitlebar')

implementation libs.androidx.constraintlayout
implementation libs.androidx.activity.compose
implementation libs.casa.ui
implementation libs.androidx.recyclerviewExt
implementation libs.androidx.cardview

// 标题栏框架:https://github.com/getActivity/TitleBar
// TBD - replace with self
// 会有资源冲突的问题,1是解决本地,2是将引用更新到最新
implementation 'com.github.getActivity:TitleBar:10.5'

// 权限请求框架:https://github.com/getActivity/XXPermissions
// TBD - replace with self
// implementation 'com.github.getActivity:XXPermissions:18.5'

// 吐司框架:https://github.com/getActivity/Toaster
// TBD - replace with self
// 直接使用aar文件,选择build module会报这个错误,虽然不影响整个app编译
// Direct local .aar file dependencies are not supported when building an AAR.
// The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies
// would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs
// in this case too (despite not throwing this error).
// The following direct local .aar file dependencies of the :app-catalog:samples:androidpft project
// caused this error: .../app-catalog/samples/androidpft/libs/Toaster-12.5.aar
implementation 'com.github.getActivity:Toaster:12.5'

// 上拉刷新下拉加载框架:https://github.com/scwang90/SmartRefreshLayout
// implementation 'io.github.scwang90:refresh-layout-kernel:2.1.0' //核心必须依赖
// implementation 'io.github.scwang90:refresh-header-material:2.1.0' //谷歌刷新头

implementation libs.androidx.navigation.fragment
implementation libs.androidx.navigation.ui
implementation libs.androidx.slidingpanelayout

implementation "io.coil-kt:coil:2.6.0"
implementation libs.coil
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wintmain.foundation.views.recyclerview.logger;
package lib.wintmain.foundation.logger;

/**
* Helper class for a list (or tree) of LoggerNodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.wintmain.foundation.views.recyclerview.logger;
package lib.wintmain.foundation.logger;

import android.graphics.Typeface;
import android.os.Bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wintmain.foundation.views.recyclerview.logger;
package lib.wintmain.foundation.logger;

/**
* Basic interface for a logging system that can output to one or more targets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wintmain.foundation.views.recyclerview.logger;
package lib.wintmain.foundation.logger;

import android.app.Activity;
import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wintmain.foundation.views.recyclerview.logger;
package lib.wintmain.foundation.logger;

import android.util.Log;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wintmain.foundation.views.recyclerview.logger;
package lib.wintmain.foundation.logger;

/**
* Simple {@link LogNode} filter, removes everything except the message.
Expand Down
17 changes: 14 additions & 3 deletions app-catalog/samples/foundation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?><!--
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2023-2024 wintmain
~
~ Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,6 +16,7 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.wintmain.foundation">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand All @@ -32,10 +34,12 @@
android:name=".telephony.callnotification.CallNotificationSample"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/Theme.AppCompat.DayNight" />
android:theme="@style/Theme.AppCompat.DayNight"
tools:targetApi="28" />
<receiver
android:name=".telephony.callnotification.CallNotificationSample$NotificationReceiver"
android:exported="false" />
android:exported="false"
tools:targetApi="28" />
<!-- callnotification END-->

<!-- networkConnectivity START-->
Expand All @@ -52,6 +56,13 @@
android:theme="@style/Theme.AppCompat.DayNight" />
<!-- recyclerview END-->

<!-- gesture detect START-->
<activity
android:name=".views.gesture.GestureDetectActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.DayNight" />
<!-- gesture detect END-->

<!-- slidingpanelayout START-->
<activity android:name=".views.layout.slidingpanelayout.SlidingPaneLayoutMain"
android:theme="@style/Theme.AppCompat.DayNight"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatTextView;
import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;
import com.hjq.bar.style.LightBarStyle;
import com.hjq.toast.Toaster;
import lib.wintmain.titlebar.OnTitleBarListener;
import lib.wintmain.titlebar.TitleBarExt;
import lib.wintmain.titlebar.style.LightBarStyle;
import lib.wintmain.toaster.toast.ToastUtils;

//@Sample(
// name = "Android PfT",
Expand All @@ -43,30 +43,30 @@ protected void onCreate(Bundle savedInstanceState) {
// 初始化一些三方库
initLibs(getApplication());

TitleBar titleBar = findViewById(R.id.tb_main_bar_click);
TitleBarExt titleBar = findViewById(R.id.tb_main_bar_click);
titleBar.setOnTitleBarListener(
new OnTitleBarListener() {

@Override
public void onLeftClick(TitleBar titleBar) {
Toaster.show("你点击了返回");
public void onLeftClick(TitleBarExt titleBar) {
ToastUtils.show("你点击了返回");
}

@Override
public void onTitleClick(TitleBar titleBar) {
Toaster.show("你点击了中间");
public void onTitleClick(TitleBarExt titleBar) {
ToastUtils.show("你点击了中间");
}

@Override
public void onRightClick(TitleBar titleBar) {
Toaster.show("你点击了设置");
public void onRightClick(TitleBarExt titleBar) {
ToastUtils.show("你点击了设置");
}
});
}

private void initLibs(Application application) {
// 初始化 TitleBar 默认样式
TitleBar.setDefaultStyle(
TitleBarExt.setDefaultStyle(
new LightBarStyle() {
@Override
public TextView newTitleView(Context context) {
Expand All @@ -85,6 +85,6 @@ public TextView newRightView(Context context) {
});

// 初始化 Toast
Toaster.init(this.getApplication());
ToastUtils.init(this.getApplication());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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.views.gesture

import android.graphics.Color
import android.os.Bundle
import android.view.Menu
import androidx.appcompat.app.AppCompatActivity
import com.google.android.catalog.framework.annotations.Sample
import com.wintmain.foundation.R
import lib.wintmain.foundation.logger.Log
import lib.wintmain.foundation.logger.LogFragment
import lib.wintmain.foundation.logger.LogWrapper
import lib.wintmain.foundation.logger.MessageOnlyLogFilter

@Sample(
name = "Gesture Detect",
description = "监听用户手势",
tags = ["android-samples", "user-interface"]
)
class GestureDetectActivity : AppCompatActivity() {
companion object {
private const val TAG = "GestureDetectActivity"
private const val FRAG = "GestureDetectFragment"
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.gesture_detect_main)

val transaction = supportFragmentManager.beginTransaction()
transaction.add(GestureDetectFragment(), FRAG).commit()
}

override fun onStart() {
super.onStart()
initializeLogging()
}

override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.gesture_main, menu)
return true
}

private fun initializeLogging() {
// Wraps Android's native log framework.
val logWrapper = LogWrapper()

// Using Log, front-end to the logging chain, emulates android.util.log method signatures.
Log.setLogNode(logWrapper)

// Filter strips out everything except the message text.
val msgFilter = MessageOnlyLogFilter()
logWrapper.next = msgFilter

// On screen logging via a fragment with a TextView.
val logFragment = supportFragmentManager
.findFragmentById(R.id.log_fragment_gesture) as LogFragment?
msgFilter.next = logFragment!!.logView
logFragment.logView.setTextAppearance(this, R.style.Log)
logFragment.logView.setBackgroundColor(Color.WHITE)
Log.i(TAG, "Ready")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.views.gesture

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.GestureDetector
import android.view.GestureDetector.SimpleOnGestureListener
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.TextView
import androidx.fragment.app.Fragment
import com.wintmain.foundation.R
import lib.wintmain.foundation.logger.LogFragment

class GestureDetectFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
}

@SuppressLint("ClickableViewAccessibility")
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

// First create the GestureListener that will include all our callbacks.
// Then create the GestureDetector, which takes that listener as an argument.
val gestureListener: SimpleOnGestureListener = GestureListener()
val gd = GestureDetector(activity, gestureListener)

/* For the view where gestures will occur, create an onTouchListener that sends
* all motion events to the gesture detector. When the gesture detector
* actually detects an event, it will use the callbacks you created in the
* SimpleOnGestureListener to alert your application.
*/
activity?.findViewById<TextView>(R.id.sample_output_gesture)?.apply {
isClickable = true
isFocusable = true
}?.setOnTouchListener { _, motionEvent ->
gd.onTouchEvent(motionEvent)
false
}
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.sample_action_gesture) {
clearLog()
}
return true
}

private fun clearLog() {
val logFragment = (requireActivity().supportFragmentManager
.findFragmentById(R.id.log_fragment_gesture) as LogFragment?)
logFragment?.logView?.text = ""
}
}
Loading
Loading