清理类库的活动窗口类到测试项目文件夹。
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| #Created by .winboll/winboll_app_build.gradle | ||||
| #Tue Mar 25 03:48:39 HKT 2025 | ||||
| #Fri Mar 28 10:26:29 GMT 2025 | ||||
| stageCount=18 | ||||
| libraryProject=libapputils | ||||
| baseVersion=15.0 | ||||
| publishVersion=15.0.17 | ||||
| buildCount=0 | ||||
| buildCount=6 | ||||
| baseBetaVersion=15.0.18 | ||||
|   | ||||
| @@ -31,6 +31,10 @@ | ||||
|  | ||||
|         <activity android:name=".TestBBMorseCodeActivity"/> | ||||
|  | ||||
|         <activity android:name=".AssetsHtmlActivity"/> | ||||
|  | ||||
|         <activity android:name=".QRCodeDecodeActivity"/> | ||||
|  | ||||
|     </application> | ||||
|  | ||||
| </manifest> | ||||
| </manifest> | ||||
| @@ -13,36 +13,6 @@ public class App extends GlobalApplication { | ||||
|  | ||||
|     public static final String TAG = "App"; | ||||
|  | ||||
|     public static final String _ACTION_DEBUGVIEW = App.class.getName() + "_ACTION_DEBUGVIEW"; | ||||
|  | ||||
|     //static volatile WinBollApplication _WinBollApplication = null; | ||||
|     //MyActivityLifecycleCallbacks mMyActivityLifecycleCallbacks; | ||||
|  | ||||
|     // 标记当前应用是否处于调试状态 | ||||
|     static volatile boolean isDebug = false; | ||||
|  | ||||
|     public synchronized static void setIsDebug(boolean isDebug) { | ||||
|         App.isDebug = isDebug; | ||||
|     } | ||||
|  | ||||
|     public static boolean isDebug() { | ||||
|         return isDebug; | ||||
|     } | ||||
|  | ||||
| //    MyActivityLifecycleCallbacks getMyActivityLifecycleCallbacks() { | ||||
| //        return mMyActivityLifecycleCallbacks; | ||||
| //    } | ||||
|  | ||||
|     @Override | ||||
|     public Context getApplicationContext() { | ||||
|         return super.getApplicationContext(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Application getApplication() { | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onCreate() { | ||||
|         super.onCreate(); | ||||
|   | ||||
| @@ -0,0 +1,152 @@ | ||||
| package cc.winboll.studio.apputils; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@QQ.COM | ||||
|  * @Date 2025/01/03 11:02:49 | ||||
|  * @Describe 一个可以浏览随 APP 附带的 Html 文档的窗口 | ||||
|  */ | ||||
| import android.app.Activity; | ||||
| import android.content.Context; | ||||
| import android.content.Intent; | ||||
| import android.net.Uri; | ||||
| import android.os.Bundle; | ||||
| import android.view.Menu; | ||||
| import android.view.MenuItem; | ||||
| import android.widget.Toolbar; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBollActivity; | ||||
| import cc.winboll.studio.apputils.R; | ||||
| import cc.winboll.studio.libapputils.view.SimpleWebView; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
|  | ||||
| public class AssetsHtmlActivity extends WinBollActivityBase implements IWinBollActivity { | ||||
|  | ||||
|     @Override | ||||
|     public Activity getActivity() { | ||||
|         return super.getActivity(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getTag() { | ||||
|         return TAG; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public static final String TAG = "AssetsHtmlActivity"; | ||||
|  | ||||
|     public static final String EXTRA_HTMLFILENAME = "EXTRA_HTMLFILENAME"; | ||||
|  | ||||
|     String mszHelpIndexFilePath = ""; | ||||
|     Uri mszHelpIndexFileUri; | ||||
|     Context mContext; | ||||
|  | ||||
|     // Assets 文件夹里的 Html 文件的名称 | ||||
|     String mszHtmlFileName; | ||||
| // | ||||
| //    @Override | ||||
| //    public Activity getActivity() { | ||||
| //        return this; | ||||
| //    } | ||||
|  | ||||
|     @Override | ||||
|     public boolean onCreateOptionsMenu(Menu menu) { | ||||
|         return super.onCreateOptionsMenu(menu); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
| //        if (item.getItemId() == android.R.id.home) { | ||||
| //            WinBollActivityManager.getInstance(this).finish(this); | ||||
| //        } | ||||
|         return super.onOptionsItemSelected(item); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         setContentView(R.layout.activity_assetshtml); | ||||
|  | ||||
|         // 初始化工具栏 | ||||
|         Toolbar mToolbar = findViewById(R.id.toolbar); | ||||
|         setActionBar(mToolbar); | ||||
|  | ||||
|         mszHtmlFileName = "index.html"; | ||||
|  | ||||
|         Intent intent = getIntent(); | ||||
|         if (intent != null) { | ||||
|             String szTemp = intent.getStringExtra(EXTRA_HTMLFILENAME); | ||||
|             if (szTemp != null && !szTemp.trim().equals("")) { | ||||
|                 mszHtmlFileName = szTemp.trim(); | ||||
|             } | ||||
|             //ToastUtils.show(mszHtmlFileName); | ||||
|         } | ||||
|  | ||||
|         // 与其他应用分享 html 帮助 | ||||
|         //FileUtils.shareHtmlFile(this, mszHelpIndexFilePath); | ||||
|  | ||||
|         // 直接读取 assets 文件显示 WebView | ||||
|         // | ||||
|         initWebViewFromAssets(mszHtmlFileName); | ||||
|  | ||||
|         // 复制 assets 文件到数据目录 files 后, | ||||
|         // 显示 WebView | ||||
|         // | ||||
| //        if (App.isDebug()) { | ||||
| //            initAssetsToSD(); | ||||
| //        } | ||||
| //        MyWebView myWebView = findViewById(R.id.activityhelpMyWebView1); | ||||
| //        myWebView.getSettings().setSupportZoom(true); | ||||
| // | ||||
| //        // 使用file协议加载本地HTML文件 | ||||
| //        //Test OK //String url = "content://cc.winboll.studio.app.beta.fileprovider/files_path/winboll/studio/html/index.html"; | ||||
| //        //myWebView.loadUrl(url); | ||||
| // | ||||
| //        myWebView.loadUrl(mszHelpIndexFileUri.toString()); | ||||
|     } | ||||
|  | ||||
|     // | ||||
|     void initWebViewFromAssets(String szHtmlFileName) { | ||||
|         try { | ||||
|             SimpleWebView webView = findViewById(R.id.activityassetshtmlSimpleWebView1); | ||||
|             webView.getSettings().setSupportZoom(true); | ||||
|             // 读取assets文件夹下的index.html文件 | ||||
|             InputStream inputStream = getAssets().open("winboll/studio/html/" + szHtmlFileName); | ||||
|             int size = inputStream.available(); | ||||
|             byte[] buffer = new byte[size]; | ||||
|             inputStream.read(buffer); | ||||
|             inputStream.close(); | ||||
|             String html = new String(buffer); | ||||
|             webView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null); | ||||
|         } catch (IOException e) { | ||||
|             LogUtils.d(TAG, e, Thread.currentThread().getStackTrace()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| //    void initAssetsToSD() { | ||||
| //        String szHtmlFileName = "index.html"; | ||||
| //        String szAssetsFilePath = "winboll/studio/html/" + szHtmlFileName; | ||||
| //        StringBuilder sbDst = new StringBuilder(); | ||||
| //        sbDst.append(getFilesDir()); | ||||
| //        sbDst.append(File.separator); | ||||
| //        sbDst.append("winboll"); | ||||
| //        sbDst.append(File.separator); | ||||
| //        sbDst.append("studio"); | ||||
| //        sbDst.append(File.separator); | ||||
| //        sbDst.append("html"); | ||||
| //        sbDst.append(File.separator); | ||||
| //        File fDstFolder = new File(sbDst.toString()); | ||||
| //        if (!fDstFolder.exists()) { | ||||
| //            fDstFolder.mkdirs(); | ||||
| //        } | ||||
| //        File fDst = new File(fDstFolder, szHtmlFileName); | ||||
| // | ||||
| //        mszHelpIndexFilePath = fDst.getPath(); | ||||
| //        mszHelpIndexFileUri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", fDst); | ||||
| // | ||||
| //        FileUtils.copyAssetsToSD(this, szAssetsFilePath, mszHelpIndexFilePath); | ||||
| // | ||||
| //        // 设置只读权限 | ||||
| //        //fDst.setReadOnly(); | ||||
| //    } | ||||
| } | ||||
| @@ -16,10 +16,6 @@ import cc.winboll.studio.apputils.R; | ||||
| import cc.winboll.studio.libappbase.LogUtils; | ||||
| import cc.winboll.studio.libappbase.LogView; | ||||
| import cc.winboll.studio.libappbase.utils.ToastUtils; | ||||
| import cc.winboll.studio.libapputils.activities.AssetsHtmlActivity; | ||||
| import cc.winboll.studio.libapputils.activities.LogActivity; | ||||
| import cc.winboll.studio.libapputils.activities.QRCodeDecodeActivity; | ||||
| import cc.winboll.studio.libapputils.view.YesNoAlertDialog; | ||||
| import java.util.List; | ||||
| import java.util.Set; | ||||
|  | ||||
| @@ -149,10 +145,10 @@ final public class MainActivity extends Activity { | ||||
|     } | ||||
|  | ||||
|     public void onTestLogActivity(View view) { | ||||
|         Intent intent = new Intent(this, LogActivity.class); | ||||
|         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); | ||||
|         intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); | ||||
|         startActivity(intent); | ||||
| //        Intent intent = new Intent(this, LogActivity.class); | ||||
| //        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); | ||||
| //        intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK); | ||||
| //        startActivity(intent); | ||||
|  | ||||
|         //WinBollActivityManager.getInstance().printAvtivityListInfo(); | ||||
|         //WinBollActivityManager.getInstance(this).startWinBollActivity(this, LogActivity.class); | ||||
| @@ -209,7 +205,7 @@ final public class MainActivity extends Activity { | ||||
| //            //ToastUtils.show("mIWinBoll.isAddWinBollToolBar()"); | ||||
| //            getMenuInflater().inflate(R.menu.toolbar_winboll_shared_main, menu); | ||||
| //        } | ||||
|         if (App.isDebug()) { | ||||
|         if (App.isDebuging()) { | ||||
|             getMenuInflater().inflate(R.menu.toolbar_studio_debug, menu); | ||||
|         } | ||||
|  | ||||
| @@ -219,7 +215,7 @@ final public class MainActivity extends Activity { | ||||
|     @Override | ||||
|     public boolean onOptionsItemSelected(MenuItem item) { | ||||
|         if (item.getItemId() == R.id.item_exit) { | ||||
|             exit(); | ||||
|             //exit(); | ||||
|             return true; | ||||
|         } else if (item.getItemId() == R.id.item_teststringtoqrcodeview) { | ||||
|             Intent intent = new Intent(this, TestStringToQRCodeViewActivity.class); | ||||
| @@ -246,21 +242,21 @@ final public class MainActivity extends Activity { | ||||
|         return super.onOptionsItemSelected(item); | ||||
|     } | ||||
|  | ||||
|     void exit() { | ||||
|         YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){ | ||||
|  | ||||
|             @Override | ||||
|             public void onYes() { | ||||
|                 //WinBollActivityManager.getInstance(getApplicationContext()).finishAll(); | ||||
|             } | ||||
|  | ||||
|             @Override | ||||
|             public void onNo() { | ||||
|             } | ||||
|         }; | ||||
|         YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener); | ||||
|  | ||||
|     } | ||||
| //    void exit() { | ||||
| //        YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){ | ||||
| // | ||||
| //            @Override | ||||
| //            public void onYes() { | ||||
| //                //WinBollActivityManager.getInstance(getApplicationContext()).finishAll(); | ||||
| //            } | ||||
| // | ||||
| //            @Override | ||||
| //            public void onNo() { | ||||
| //            } | ||||
| //        }; | ||||
| //        YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener); | ||||
| // | ||||
| //    } | ||||
|  | ||||
|     @Override | ||||
|     public void onBackPressed() { | ||||
|   | ||||
| @@ -0,0 +1,107 @@ | ||||
| package cc.winboll.studio.apputils; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@QQ.COM | ||||
|  * @Date 2025/01/18 10:32:21 | ||||
|  * @Describe 二维码扫码解码窗口 | ||||
|  */ | ||||
| import android.app.Activity; | ||||
| import android.content.Intent; | ||||
| import android.content.pm.PackageManager; | ||||
| import android.os.Bundle; | ||||
| import android.widget.TextView; | ||||
| import android.widget.Toolbar; | ||||
| import cc.winboll.studio.apputils.R; | ||||
| import com.google.zxing.ResultPoint; | ||||
| import com.journeyapps.barcodescanner.BarcodeCallback; | ||||
| import com.journeyapps.barcodescanner.BarcodeResult; | ||||
| import com.journeyapps.barcodescanner.DecoratedBarcodeView; | ||||
| import java.util.List; | ||||
|  | ||||
| public class QRCodeDecodeActivity extends Activity { | ||||
|  | ||||
|     public static final String TAG = "QRCodeDecodeActivity"; | ||||
|  | ||||
|     public static final String EXTRA_RESULT = "EXTRA_RESULT"; | ||||
|     private static final int REQUEST_CAMERA_PERMISSION = 1; | ||||
|  | ||||
|     TextView resultTextView; | ||||
|     DecoratedBarcodeView barcodeView; | ||||
|  | ||||
| //    @Override | ||||
| //    public Activity getActivity() { | ||||
| //        return this; | ||||
| //    } | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         setContentView(R.layout.activity_qrcodedecode); | ||||
|  | ||||
|         // 初始化工具栏 | ||||
| //        Toolbar mToolbar = findViewById(R.id.toolbar); | ||||
| //        setActionBar(mToolbar); | ||||
|  | ||||
|         //resultTextView = findViewById(R.id.activityqrcodedecodeTextView1); | ||||
|         barcodeView = findViewById(R.id.activityqrcodedecodeDecoratedBarcodeView1); | ||||
|         // 请求相机权限 | ||||
| //        if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) | ||||
| //            != PackageManager.PERMISSION_GRANTED) { | ||||
| //            ActivityCompat.requestPermissions(this, | ||||
| //                                              new String[]{android.Manifest.permission.CAMERA}, | ||||
| //                                              REQUEST_CAMERA_PERMISSION); | ||||
| //        } else { | ||||
| //            startScanning(); | ||||
| //        } | ||||
|         startScanning(); | ||||
|     } | ||||
|  | ||||
|     private void startScanning() { | ||||
|         barcodeView.getBarcodeView().setDecoderFactory(null); | ||||
|         barcodeView.decodeContinuous(barcodeCallback); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onRequestPermissionsResult(int requestCode, | ||||
|                                            String[] permissions, int[] grantResults) { | ||||
|         if (requestCode == REQUEST_CAMERA_PERMISSION) { | ||||
|             if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||||
|                 startScanning(); | ||||
|             } else { | ||||
|                 // 权限被拒绝的处理 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     BarcodeCallback barcodeCallback = new BarcodeCallback(){ | ||||
|         @Override | ||||
|         public void barcodeResult(BarcodeResult result) { | ||||
|             if (result.getText() != null) { | ||||
|                 //Toast.makeText(MainActivity.this, "Scanned: " + result.getText(), Toast.LENGTH_SHORT).show(); | ||||
|                 //ToastUtils.show("Scanned: " + result.getText()); | ||||
|                 barcodeView.pause(); | ||||
|                 Intent intent = new Intent(); | ||||
|                 intent.putExtra(EXTRA_RESULT, result.getText()); | ||||
|                 setResult(RESULT_OK, intent); | ||||
|                 finish(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public void possibleResultPoints(List<ResultPoint> resultPoints) { | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     @Override | ||||
|     protected void onResume() { | ||||
|         super.onResume(); | ||||
|         barcodeView.resume(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onPause() { | ||||
|         super.onPause(); | ||||
|         barcodeView.pause(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,52 @@ | ||||
| package cc.winboll.studio.apputils; | ||||
|  | ||||
| /** | ||||
|  * @Author ZhanGSKen@AliYun.Com | ||||
|  * @Date 2025/03/28 17:11:37 | ||||
|  * @Describe 应用活动窗口基类 | ||||
|  */ | ||||
| import android.app.Activity; | ||||
| import android.os.Bundle; | ||||
| import android.os.PersistableBundle; | ||||
| import android.support.v7.app.AppCompatActivity; | ||||
| import cc.winboll.studio.libappbase.GlobalApplication; | ||||
| import cc.winboll.studio.libappbase.winboll.IWinBollActivity; | ||||
| import cc.winboll.studio.libappbase.winboll.WinBollActivityManager; | ||||
|  | ||||
| public class WinBollActivityBase extends AppCompatActivity implements IWinBollActivity { | ||||
|  | ||||
|     public static final String TAG = "WinBollActivityBase"; | ||||
|  | ||||
|     @Override | ||||
|     public Activity getActivity() { | ||||
|         return this; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public String getTag() { | ||||
|         return TAG; | ||||
|     } | ||||
|  | ||||
|     WinBollActivityManager getWinBollActivityManager() { | ||||
|         return WinBollActivityManager.getInstance(GlobalApplication.getInstance()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void onCreate(Bundle savedInstanceState) { | ||||
|         super.onCreate(savedInstanceState); | ||||
|         getWinBollActivityManager().add(this); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) { | ||||
|         super.onPostCreate(savedInstanceState, persistentState); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|     @Override | ||||
|     protected void onDestroy() { | ||||
|         super.onDestroy(); | ||||
|         getWinBollActivityManager().registeRemove(this); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										21
									
								
								apputils/src/main/res/layout/activity_assetshtml.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								apputils/src/main/res/layout/activity_assetshtml.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:orientation="vertical" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent"> | ||||
|  | ||||
|     <android.widget.Toolbar | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:id="@+id/toolbar"/> | ||||
|  | ||||
|     <cc.winboll.studio.libapputils.view.SimpleWebView | ||||
|         android:layout_width="match_parent" | ||||
|         android:layout_height="0dp" | ||||
|         android:layout_weight="1.0" | ||||
|         android:id="@+id/activityassetshtmlSimpleWebView1"/> | ||||
|  | ||||
| </LinearLayout> | ||||
|  | ||||
							
								
								
									
										20
									
								
								apputils/src/main/res/layout/activity_qrcodedecode.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								apputils/src/main/res/layout/activity_qrcodedecode.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <LinearLayout | ||||
|     xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     xmlns:app="http://schemas.android.com/apk/res-auto" | ||||
|     android:orientation="vertical" | ||||
|     android:layout_width="match_parent" | ||||
|     android:layout_height="match_parent"> | ||||
|  | ||||
|     <TextView | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:text="QRCodeDecodeActivity"/> | ||||
|  | ||||
|     <com.journeyapps.barcodescanner.DecoratedBarcodeView | ||||
|         android:layout_width="wrap_content" | ||||
|         android:layout_height="wrap_content" | ||||
|         android:id="@+id/activityqrcodedecodeDecoratedBarcodeView1"/> | ||||
|  | ||||
| </LinearLayout> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen