From 9ffa005b6391fdf9ee9cf10a52611ac02fdc1236 Mon Sep 17 00:00:00 2001 From: zhangnaifu15 <1361423499@qq.com> Date: Tue, 12 Jun 2018 11:34:33 +0800 Subject: [PATCH] src\MyApplication\.idea\compiler.xml --- src/MyApplication/app/build.gradle | 4 +- .../app/src/main/AndroidManifest.xml | 77 ++-- .../myapplication/app/BaseApplication.java | 20 +- .../myapplication/entity/Entity.java | 32 -- .../ui/AppCompatPreferenceActivity.java | 109 ----- .../myapplication/ui/DateTimePicker.java | 4 +- .../myapplication/ui/EditImages.java | 15 - .../myapplication/ui/EditNotes.java | 23 -- .../myapplication/ui/ImagesDisplay.java | 35 -- .../myapplication/ui/ListActivity.java | 36 -- .../myapplication/ui/MainActivity.java | 33 +- .../myapplication/ui/NoteBookFragment.java | 23 +- .../myapplication/ui/NoteEditFragment.java | 4 +- .../myapplication/ui/ScanImages.java | 23 -- .../myapplication/ui/SearchActivity.java | 15 - .../myapplication/ui/SignActivity.java | 30 -- .../myapplication/ui/app_bar_activity.java | 25 -- .../myapplication/utils/CommonUtils.java | 8 +- .../myapplication/utils/Constants.java | 4 +- .../myapplication/utils/DialogHelp.java | 2 +- .../myapplication/utils/ImageLoadOptions.java | 4 +- .../myapplication/utils/MD5Util.java | 4 +- .../myapplication/utils/PhotoUtil.java | 63 ++- .../myapplication/utils/ResourceParser.java | 2 +- .../myapplication/utils/SPUtils.java | 2 +- .../myapplication/utils/StringUtils.java | 5 +- .../myapplication/utils/SystemUtils.java | 3 +- .../myapplication/utils/TimeZoneUtil.java | 6 +- .../webview/APIWebViewActivity.java | 385 ------------------ .../myapplication/webview/WebActivity.java | 120 ------ .../myapplication/widget/HTQDragGridView.java | 33 +- .../widget/NoteItemCircleView.java | 3 +- .../myapplication/widget/ToggleButton.java | 3 +- .../widget/patternlock/LockPatternView.java | 1 - .../main/res/layout/activity_api_webview.xml | 29 -- .../main/res/layout/activity_edit_images.xml | 134 ------ .../main/res/layout/activity_edit_notes.xml | 38 -- .../res/layout/activity_images_display.xml | 128 ------ .../app/src/main/res/layout/activity_list.xml | 115 ------ .../main/res/layout/activity_scan_images.xml | 20 - .../src/main/res/layout/activity_search.xml | 91 ----- .../app/src/main/res/layout/activity_sign.xml | 101 ----- .../app/src/main/res/layout/activity_web.xml | 19 - .../src/main/res/layout/activity_welcome.xml | 8 +- .../app/src/main/res/layout/app_bar_main.xml | 81 +--- .../app/src/main/res/menu/main.xml | 4 +- .../app/src/main/res/values/strings.xml | 6 +- src/MyApplication/build.gradle | 5 + src/MyApplication/library/.gitignore | 1 - src/MyApplication/library/build.gradle | 24 -- src/MyApplication/library/proguard-rules.pro | 25 -- .../library/src/main/AndroidManifest.xml | 10 - .../action/web/ActionSelectListener.java | 9 - .../shuyu/action/web/CustomActionWebView.java | 159 -------- .../library/src/main/res/values/strings.xml | 3 - 55 files changed, 196 insertions(+), 1970 deletions(-) delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/AppCompatPreferenceActivity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditImages.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditNotes.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ImagesDisplay.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ListActivity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ScanImages.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/SearchActivity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/SignActivity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/app_bar_activity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/webview/APIWebViewActivity.java delete mode 100644 src/MyApplication/app/src/main/java/com/example/administrator/myapplication/webview/WebActivity.java delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_api_webview.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_edit_images.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_edit_notes.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_images_display.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_list.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_scan_images.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_search.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_sign.xml delete mode 100644 src/MyApplication/app/src/main/res/layout/activity_web.xml delete mode 100644 src/MyApplication/library/.gitignore delete mode 100644 src/MyApplication/library/build.gradle delete mode 100644 src/MyApplication/library/proguard-rules.pro delete mode 100644 src/MyApplication/library/src/main/AndroidManifest.xml delete mode 100644 src/MyApplication/library/src/main/java/com/shuyu/action/web/ActionSelectListener.java delete mode 100644 src/MyApplication/library/src/main/java/com/shuyu/action/web/CustomActionWebView.java delete mode 100644 src/MyApplication/library/src/main/res/values/strings.xml diff --git a/src/MyApplication/app/build.gradle b/src/MyApplication/app/build.gradle index 7e50609..52c9085 100644 --- a/src/MyApplication/app/build.gradle +++ b/src/MyApplication/app/build.gradle @@ -45,6 +45,7 @@ dependencies { androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) + compile project(':floatwindow') compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.jakewharton:butterknife:8.2.1' @@ -57,8 +58,7 @@ dependencies { compile 'org.greenrobot:eventbus:3.0.0' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.2' compile 'com.github.clans:fab:1.6.1' - testCompile 'junit:junit:4.12' compile 'com.github.yhaolpz:FloatWindow:1.0.9' + testCompile 'junit:junit:4.12' apt 'com.jakewharton:butterknife-compiler:8.2.1' - compile project(':floatwindow') } diff --git a/src/MyApplication/app/src/main/AndroidManifest.xml b/src/MyApplication/app/src/main/AndroidManifest.xml index 1a6c8c3..44aeee6 100644 --- a/src/MyApplication/app/src/main/AndroidManifest.xml +++ b/src/MyApplication/app/src/main/AndroidManifest.xml @@ -1,44 +1,44 @@ + package="com.example.administrator.myapplication" + android:versionCode="1" + android:versionName="2.1.0"> - - + + - + - + - - - + + + - + - - - - + + + + + android:theme="@style/AppTheme"> - + - + + android:value="@integer/google_play_services_version" /> - + - + - - + + - + + android:theme="@style/AppTheme.NoActionBar" /> - + android:theme="@style/AppTheme.NoActionBar"> - + android:theme="@style/AppTheme.NoActionBar"> - + android:theme="@style/AppTheme.NoActionBar"> - + android:theme="@style/AppTheme.NoActionBar"> - + android:theme="@style/AppTheme.NoActionBar"> + android:resource="@xml/provider_paths" /> - + android:process=":remote"> - - + + + diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java index b20947d..6dcd7b1 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/app/BaseApplication.java @@ -16,6 +16,7 @@ import com.example.administrator.myapplication.entity.NotebookData; import com.example.administrator.myapplication.entity.OnResponseListener; import com.example.administrator.myapplication.entity.Response; import com.example.administrator.myapplication.ui.MainActivity; +import com.example.administrator.myapplication.utils.AccountUtils; import com.example.administrator.myapplication.utils.BmobConstants; import com.example.administrator.myapplication.utils.Constants; import com.example.administrator.myapplication.utils.SPUtils; @@ -83,17 +84,30 @@ public class BaseApplication extends Application { ClipData.Item item = clipData.getItemAt(0); String text = item.getText().toString(); System.out.println(text); - //将剪切板内容转化为notebookdata - noteDb = new NoteDatabase(getApplicationContext()); + //将剪切板内容转化为notebookdate editData = new NotebookData(); + if (editData.getId() == 0) { + editData.setId(-1 + * StringUtils.toInt( + StringUtils.getDataTime("dddHHmmss"), 0)); + } + String userId = AccountUtils.getUserId(getApplicationContext()); + editData.setUserId(userId); + editData.setObjectId(editData.getObjectId()); + editData.setUnixTime(StringUtils.getDataTime("yyyy-MM-dd HH:mm:ss")); + editData.setIid(editData.getIid()+1); editData.setContent(text); + editData.setDate(editData.getDate()); + //editData.setUserId("23ee9374c5"); + //editData.setColor(3);//默认为blue + //editData.setColorText("blue"); isNewNote = true; if (StringUtils.isEmpty(editData.getDate())) { editData.setDate(StringUtils.getDataTime("yyyy/MM/dd")); } mFontSizeId= (int) SPUtils.get(getApplicationContext(),Constants.TEXT_SIZE, Constants.TEXT_MEDIUM); - System.out.println(editData.getContent()); + //System.out.println(editData.getContent()); editData.postNoteToServer(getApplicationContext(), new OnResponseListener() { @Override diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java deleted file mode 100644 index c40e9c3..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/entity/Entity.java +++ /dev/null @@ -1,32 +0,0 @@ -//package com.htq.baidu.coolnote.entity; -// -// -//import java.io.Serializable; -// -//import cn.bmob.v3.BmobObject; -// -// -//@SuppressWarnings("serial") -//public abstract class Entity extends BmobObject implements Serializable { -// -// -// protected int id; -// -// protected String cacheKey; -// -// public int getId() { -// return id; -// } -// -// public void setId(int id) { -// this.id = id; -// } -// -// public String getCacheKey() { -// return cacheKey; -// } -// -// public void setCacheKey(String cacheKey) { -// this.cacheKey = cacheKey; -// } -//} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/AppCompatPreferenceActivity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/AppCompatPreferenceActivity.java deleted file mode 100644 index e89953b..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/AppCompatPreferenceActivity.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.example.administrator.myapplication.ui; - -import android.content.res.Configuration; -import android.os.Bundle; -import android.preference.PreferenceActivity; -import android.support.annotation.LayoutRes; -import android.support.annotation.Nullable; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatDelegate; -import android.support.v7.widget.Toolbar; -import android.view.MenuInflater; -import android.view.View; -import android.view.ViewGroup; - -/** - * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls - * to be used with AppCompat. - */ -public abstract class AppCompatPreferenceActivity extends PreferenceActivity { - - private AppCompatDelegate mDelegate; - - @Override - protected void onCreate(Bundle savedInstanceState) { - getDelegate().installViewFactory(); - getDelegate().onCreate(savedInstanceState); - super.onCreate(savedInstanceState); - } - - @Override - protected void onPostCreate(Bundle savedInstanceState) { - super.onPostCreate(savedInstanceState); - getDelegate().onPostCreate(savedInstanceState); - } - - public ActionBar getSupportActionBar() { - return getDelegate().getSupportActionBar(); - } - - public void setSupportActionBar(@Nullable Toolbar toolbar) { - getDelegate().setSupportActionBar(toolbar); - } - - @Override - public MenuInflater getMenuInflater() { - return getDelegate().getMenuInflater(); - } - - @Override - public void setContentView(@LayoutRes int layoutResID) { - getDelegate().setContentView(layoutResID); - } - - @Override - public void setContentView(View view) { - getDelegate().setContentView(view); - } - - @Override - public void setContentView(View view, ViewGroup.LayoutParams params) { - getDelegate().setContentView(view, params); - } - - @Override - public void addContentView(View view, ViewGroup.LayoutParams params) { - getDelegate().addContentView(view, params); - } - - @Override - protected void onPostResume() { - super.onPostResume(); - getDelegate().onPostResume(); - } - - @Override - protected void onTitleChanged(CharSequence title, int color) { - super.onTitleChanged(title, color); - getDelegate().setTitle(title); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - getDelegate().onConfigurationChanged(newConfig); - } - - @Override - protected void onStop() { - super.onStop(); - getDelegate().onStop(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - getDelegate().onDestroy(); - } - - public void invalidateOptionsMenu() { - getDelegate().invalidateOptionsMenu(); - } - - private AppCompatDelegate getDelegate() { - if (mDelegate == null) { - mDelegate = AppCompatDelegate.create(this, null); - } - return mDelegate; - } -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/DateTimePicker.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/DateTimePicker.java index 285bb27..cffcb4d 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/DateTimePicker.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/DateTimePicker.java @@ -11,9 +11,7 @@ import com.example.administrator.myapplication.R; import java.text.DateFormatSymbols; import java.util.Calendar; -/** - * Created by htq on 2016/9/13. - */ + public class DateTimePicker extends FrameLayout { private static final boolean DEFAULT_ENABLE_STATE = true; diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditImages.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditImages.java deleted file mode 100644 index f1fd3ad..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditImages.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.administrator.myapplication.ui; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; - -import com.example.administrator.myapplication.R; - -public class EditImages extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_edit_images); - } -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditNotes.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditNotes.java deleted file mode 100644 index 21c1a51..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/EditNotes.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.example.administrator.myapplication.ui; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.View; - -import com.example.administrator.myapplication.R; - -public class EditNotes extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_edit_notes); - findViewById(R.id.picture_back).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(EditNotes.this, ListActivity.class)); - } - }); - } -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ImagesDisplay.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ImagesDisplay.java deleted file mode 100644 index 1cab5b3..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ImagesDisplay.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.example.administrator.myapplication.ui; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.View; - -import com.example.administrator.myapplication.R; - -public class ImagesDisplay extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_images_display); - findViewById(R.id.note_btn).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(ImagesDisplay.this, ListActivity.class)); - } - }); - findViewById(R.id.search_btn).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(ImagesDisplay.this, SearchActivity.class)); - } - }); - findViewById(R.id.p5).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(ImagesDisplay.this, ScanImages.class)); - } - }); - } -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ListActivity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ListActivity.java deleted file mode 100644 index b8269fd..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/ListActivity.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.example.administrator.myapplication.ui; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.View; - -import com.example.administrator.myapplication.R; - -public class ListActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_list); - findViewById(R.id.note_btn).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(ListActivity.this, ImagesDisplay.class)); - } - }); - findViewById(R.id.search_btn).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(ListActivity.this, SearchActivity.class)); - } - }); - findViewById(R.id.textView3).setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View v){ - startActivity(new Intent(ListActivity.this, EditNotes.class)); - } - }); - - } -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/MainActivity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/MainActivity.java index d76c3fa..5a067a0 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/MainActivity.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/MainActivity.java @@ -8,17 +8,22 @@ import android.os.SystemClock; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.NavigationView; import android.support.design.widget.Snackbar; +import android.support.design.widget.TabItem; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.view.GravityCompat; +import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; -import android.support.v7.widget.Toolbar; -import android.support.v7.app.AppCompatActivity; import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.widget.ImageView; +import android.widget.TableLayout; +import android.widget.TextView; import com.example.administrator.myapplication.R; import com.example.administrator.myapplication.db.NoteDatabase; @@ -43,6 +48,7 @@ public class MainActivity extends AppCompatActivity private NoteBookFragment noteBookFragment; private ImageView headIcon; private View baseView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -59,6 +65,23 @@ public class MainActivity extends AppCompatActivity // User.refreshAvatarFromLocal(BmobConstants.MyAvatarDir+"avatarIcon.png",headIcon); //注册EventBus EventBus.getDefault().register(this); +// Button picView = findViewById(R.id.app_bar_item2); +// picView.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// setContentView(R.layout.pic_view); +// } +// }); + +// +// View picView = (View) findViewById(R.id.app_bar_tablayout); +// picView.setOnClickListener(new View.OnClickListener(){ +// @Override +// public void onClick(View view) { +// Intent intent = new Intent(MainActivity.this,pic_view.class); +// startActivity(intent); +// } +// }); } /** @@ -69,10 +92,8 @@ public class MainActivity extends AppCompatActivity public void onEventBackgroundThread(UpdataEvent event) { if (event.getType() == UpdataEvent.UPDATE_USER_INFOS) { User.initDefaultAvatar(this,headIcon); - //Snackbar.make(headIcon,"update",Snackbar.LENGTH_LONG).show(); - // mPresenter.setUserNickName(); - - + Snackbar.make(headIcon,"update",Snackbar.LENGTH_LONG).show(); + //mPresenter.setUserNickName(); } } diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/NoteBookFragment.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/NoteBookFragment.java index 7d893c5..879cd79 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/NoteBookFragment.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/ui/NoteBookFragment.java @@ -255,13 +255,13 @@ public void getServerData() getServerData(); adapter.refurbishData(datas); noteDb.reset(datas);//将结果重置到数据库 -// for(int i=0;i - * 1、内存泄漏防备 - * 2、配置webView - * 3、页面加载开始,错误,拦截请求,接受Error等 - * 4、页面加载进度,title,图标,js弹框等 - * 5、js交互与安全 - */ -public class APIWebViewActivity extends AppCompatActivity implements View.OnClickListener { - - FrameLayout mRootLayout; - WebView mWebView; - Button mButton; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_api_webview); - - findViewById(R.id.call_js_function).setOnClickListener(this); - - //添加webView到布局中 - addWebViewToLayout(); - - //set webView Setting - setWebView(); - - //set webView Client - setWebClient(); - - //set webView chrome - setWebViewChromeClient(); - - //load web - loadUrl(); - - } - - /** - * 主动清空销毁来避免内存泄漏 - */ - @Override - protected void onDestroy() { - if (mWebView != null) { - mWebView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null); - mWebView.clearHistory(); - ((ViewGroup) mWebView.getParent()).removeView(mWebView); - mWebView.destroy(); - mWebView = null; - } - super.onDestroy(); - } - - - /** - * 1、不在xml中定义Webview,而是在需要的时候在Activity中创建 - * 使用getApplicationgContext(),避免内存泄漏。 - *

- * 2、当然,你也可以配置webView所在Activity, - * 在AndroidManifest中的进程为:android:process=":remote" - * 避免泄漏影响主进程 - **/ - void addWebViewToLayout() { - mRootLayout = (FrameLayout) findViewById(R.id.js_root_layout); - FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - mWebView = new WebView(getApplicationContext()); - mWebView.setLayoutParams(params); - mRootLayout.addView(mWebView); - } - - - /** - * 配置webView - */ - void setWebView() { - //声明WebSettings子类 - WebSettings webSettings = mWebView.getSettings(); - - //支持Javascript交互 - webSettings.setJavaScriptEnabled(true); - - - //设置自适应屏幕,两者合用 - webSettings.setUseWideViewPort(true); //将图片调整到适合webview的大小 - webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕的大小 - - //缩放操作 - webSettings.setSupportZoom(true); //支持缩放,默认为true。是下面那个的前提。 - webSettings.setBuiltInZoomControls(true); //设置内置的缩放控件。若为false,则该WebView不可缩放 - webSettings.setDisplayZoomControls(false); //隐藏原生的缩放控件 - - //其他细节操作 - //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存 - webSettings.setAllowFileAccess(true); //设置可以访问文件 - - //对于不需要使用 file 协议的应用,禁用 file 协议;防止文件泄密,file协议即是file:// - //webSettings.setAllowFileAccess(false); - //webSettings.setAllowFileAccessFromFileURLs(false); - //webSettings.setAllowUniversalAccessFromFileURLs(false); - - - - webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通过JS打开新窗口 - webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片 - webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式 - - mWebView.setDownloadListener(new DownloadListener() { - @Override - public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { - //网页中触发下载动作 - } - }); - - //增加js交互接口 - mWebView.addJavascriptInterface(new JsCallAndroidInterface(), "JSCallBackInterface"); - } - - /** - * 设置webView的Client,如页面加载开始,错误,拦截请求,接受Error等 - */ - void setWebClient() { - mWebView.setWebViewClient(new WebViewClient() { - - //拦截页面中的url加载,21以下的 - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (resolveShouldLoadLogic(url)) { - return true; - } - return super.shouldOverrideUrlLoading(view, url); - } - - //拦截页面中的url加载,21以上的 - @TargetApi(21) - @Override - public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { - if (resolveShouldLoadLogic(request.getUrl().toString())) { - return true; - } - return super.shouldOverrideUrlLoading(view, request); - } - - //页面开始加载 - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - } - - //页面加载完成 - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - } - - //页面加载每一个资源,如图片 - @Override - public void onLoadResource(WebView view, String url) { - super.onLoadResource(view, url); - } - - //监听WebView发出的请求并做相应的处理 - //浏览器的渲染以及资源加载都是在一个线程中,如果在shouldInterceptRequest处理时间过长,WebView界面就会阻塞 - //21以下的 - @Override - public WebResourceResponse shouldInterceptRequest(WebView view, String url) { - return super.shouldInterceptRequest(view, url); - } - - //监听WebView发出的请求并做相应的处理 - //浏览器的渲染以及资源加载都是在一个线程中,如果在shouldInterceptRequest处理时间过长,WebView界面就会阻塞 - //21以上的 - @Override - public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { - return super.shouldInterceptRequest(view, request); - } - - //页面加载出现错误,23以下的 - @Override - public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { - super.onReceivedError(view, errorCode, description, failingUrl); - switch (errorCode) { - case 404: - //view.loadUrl("加载一个错误页面提示,优化体验"); - break; - } - } - - //页面加载出现错误,23以上的 - @TargetApi(23) - @Override - public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { - super.onReceivedError(view, request, error); - switch (error.getErrorCode()) { - case 404: - //view.loadUrl("加载一个错误页面提示,优化体验"); - break; - } - - } - - //https错误 - @Override - public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { - super.onReceivedSslError(view, handler, error); - } - }); - } - - /** - * 设置webView的辅助功能,如页面加载进度,title,图标,js弹框等 - */ - void setWebViewChromeClient() { - mWebView.setWebChromeClient(new WebChromeClient() { - - //页面加载进度 - @Override - public void onProgressChanged(WebView view, int newProgress) { - super.onProgressChanged(view, newProgress); - } - - //获取标题 - @Override - public void onReceivedTitle(WebView view, String title) { - super.onReceivedTitle(view, title); - } - - //获取图标 - @Override - public void onReceivedIcon(WebView view, Bitmap icon) { - super.onReceivedIcon(view, icon); - } - - //是否支持页面中的js警告弹出框 - @Override - public boolean onJsAlert(WebView view, String url, String message, JsResult result) { - - Toast.makeText(APIWebViewActivity.this, message, Toast.LENGTH_SHORT).show(); - - return super.onJsAlert(view, url, message, result); - } - - //是否支持页面中的js确定弹出框 - @Override - public boolean onJsConfirm(WebView view, String url, String message, JsResult result) { - return super.onJsConfirm(view, url, message, result); - } - - //是否支持页面中的js输入弹出框 - @Override - public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { - /** - * 有时候,为了安全考虑,js的参数回调,会通过这类地方回调回来,然后不弹出框。 - */ - if(resolveJSPrompt(message)) { - return true; - } - return super.onJsPrompt(view, url, message, defaultValue, result); - - } - }); - } - - /** - * 加载url - */ - void loadUrl() { - // 格式规定为:file:///android_asset/文件名.html - mWebView.loadUrl("file:///android_asset/localHtml.html"); - //方式1. 加载远程网页: - //mWebView.loadUrl("http://www.baidu.com/"); - //方式2:加载asset的html页面 - //mWebView.loadUrl("file:///android_asset/localHtml.html"); - //方式3:加载手机SD的html页面 - //mWebView.loadUrl("file:///mnt/sdcard/database/taobao.html"); - } - - /** - * 执行网页中的js方法 - */ - void callJsFunction() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - mWebView.evaluateJavascript("javascript:callJS()", new ValueCallback() { - @Override - public void onReceiveValue(String value) { - //接受返回值 - } - }); - } else { - mWebView.loadUrl("javascript:callJS()"); - } - } - - /** - * js与web交互1 - * js 与 原生交互接口 - */ - private class JsCallAndroidInterface { - - //@JavascriptInterface注解方法,js端调用,4.2以后安全 - //4.2以前,当JS拿到Android这个对象后,就可以调用这个Android对象中所有的方法,包括系统类(java.lang.Runtime 类),从而进行任意代码执行。 - @JavascriptInterface - public void callback(String msg) { - Toast.makeText(APIWebViewActivity.this, "JS方法回调到web了 :" + msg, Toast.LENGTH_SHORT).show(); - } - } - - /** - * js与web交互2 - * 通过 shouldOverrideUrlLoading 与 js交互 - */ - private boolean resolveShouldLoadLogic(String url) { - Uri uri = Uri.parse(url); - //解析协议 - if (uri.getScheme().equals("js")) { - if (uri.getAuthority().equals("Authority")) { - //你还可以继续接续参数 - //Set collection = uri.getQueryParameterNames(); - Toast.makeText(APIWebViewActivity.this, "JS 2方法回调到web了", Toast.LENGTH_SHORT).show(); - - } - return true; - } - return false; - } - - /** - * js与web交互3 - * 通过 onJsPrompt 与 js交互 - */ - private boolean resolveJSPrompt(String message) { - Uri uri = Uri.parse(message); - if ( uri.getScheme().equals("js")) { - if (uri.getAuthority().equals("Authority")) { - - //Set collection = uri.getQueryParameterNames(); - //参数result:代表消息框的返回值(输入值) - //result.confirm("JS 3方法回调到web"); - Toast.makeText(APIWebViewActivity.this, "JS 3方法回调到web了", Toast.LENGTH_SHORT).show(); - } - return true; - } - return false; - } - - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.call_js_function: - callJsFunction(); - break; - } - } -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/webview/WebActivity.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/webview/WebActivity.java deleted file mode 100644 index 52f6c81..0000000 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/webview/WebActivity.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.example.administrator.myapplication.webview; - -import android.graphics.Bitmap; -import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.view.View; -import android.webkit.WebResourceError; -import android.webkit.WebResourceRequest; -import android.webkit.WebView; -import android.webkit.WebViewClient; -import android.widget.Toast; - -import com.example.administrator.myapplication.R; -import com.shuyu.action.web.ActionSelectListener; -import com.shuyu.action.web.CustomActionWebView; - -import java.util.ArrayList; -import java.util.List; - -public class WebActivity extends AppCompatActivity { - - - View mLadingView; - CustomActionWebView mCustomActionWebView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_web); - - mLadingView = findViewById(R.id.loadingView); - mCustomActionWebView = (CustomActionWebView)findViewById(R.id.customActionWebView); - - - List list = new ArrayList<>(); - list.add("复制"); - list.add("粘贴"); - list.add("一键嗖藏"); - - mCustomActionWebView.setWebViewClient(new CustomWebViewClient()); - - //设置item - mCustomActionWebView.setActionList(list); - - //链接js注入接口,使能选中返回数据 - mCustomActionWebView.linkJSInterface(); - - mCustomActionWebView.getSettings().setBuiltInZoomControls(true); - mCustomActionWebView.getSettings().setDisplayZoomControls(false); - //使用javascript - mCustomActionWebView.getSettings().setJavaScriptEnabled(true); - mCustomActionWebView.getSettings().setDomStorageEnabled(true); - - - //增加点击回调 - mCustomActionWebView.setActionSelectListener(new ActionSelectListener() { - @Override - public void onClick(String title, String selectText) { - if(title.equals("一键嗖藏")) { - Toast.makeText(WebActivity.this, "Click Item: " + title + "。\n\nValue: " + selectText, Toast.LENGTH_LONG).show(); - - return; - } - //System.out.println(title + selectText); - Toast.makeText(WebActivity.this, "Click Item: " + title + "。\n\nValue: " + selectText, Toast.LENGTH_LONG).show(); - } - }); - - //加载url - mCustomActionWebView.postDelayed(new Runnable() { - @Override - public void run() { - mCustomActionWebView.loadUrl("https://www.cnblogs.com/joy99/p/6343237.html"); - } - }, 1000); - } - - - @Override - protected void onPause() { - super.onPause(); - if(mCustomActionWebView != null) { - mCustomActionWebView.dismissAction(); - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - - } - - private class CustomWebViewClient extends WebViewClient { - - private boolean mLastLoadFailed = false; - - @Override - public void onPageFinished(WebView webView, String url) { - super.onPageFinished(webView, url); - if (!mLastLoadFailed) { - CustomActionWebView customActionWebView = (CustomActionWebView) webView; - customActionWebView.linkJSInterface(); - mLadingView.setVisibility(View.GONE); - } - } - - @Override - public void onPageStarted(WebView webView, String url, Bitmap favicon) { - super.onPageStarted(webView, url, favicon); - } - - @Override - public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { - super.onReceivedError(view, request, error); - mLastLoadFailed = true; - mLadingView.setVisibility(View.GONE); - } - } - -} diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/HTQDragGridView.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/HTQDragGridView.java index ce2ad8f..de38359 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/HTQDragGridView.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/HTQDragGridView.java @@ -29,10 +29,7 @@ import java.util.LinkedList; import java.util.List; /** - * 感谢这篇博客的作者,http://blog.csdn.net/xiaanming/article/details/17718579
- * 在这个基础上解决了原作者的问题:Adapter无法使用ViewHolder优化的问题,优化了手势识别率,并添加了trashView功能, - * 优化自定义控件对外扩展性,解决在上下拉环境下手势冲突问题
- * + * 跨屏滑动 * */ public class HTQDragGridView extends GridView { @@ -110,9 +107,7 @@ public class HTQDragGridView extends GridView { /** * 获取状态栏的高度 - * - * @param context - * @return + * */ private static int getStatusHeight(Context context) { int statusHeight = 0; @@ -175,7 +170,6 @@ public class HTQDragGridView extends GridView { /** * 若设置为AUTO_FIT,计算有多少列 */ - @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (mNumColumns == AUTO_FIT) { int numFittedColumns = 1; // 可用列 @@ -202,7 +196,7 @@ public class HTQDragGridView extends GridView { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } - @Override + protected void onDraw(Canvas canvas) { super.onDraw(canvas); initRecord(); @@ -226,7 +220,6 @@ public class HTQDragGridView extends GridView { /******************** preference method ********************/ - @Override public void setAdapter(ListAdapter adapter) { super.setAdapter(adapter); @@ -238,20 +231,20 @@ public class HTQDragGridView extends GridView { } } - @Override + public void setNumColumns(int numColumns) { super.setNumColumns(numColumns); mNumColumnsSet = true; this.mNumColumns = numColumns; } - @Override + public void setColumnWidth(int columnWidth) { super.setColumnWidth(columnWidth); mColumnWidth = columnWidth; } - @Override + public void setHorizontalSpacing(int horizontalSpacing) { super.setHorizontalSpacing(horizontalSpacing); this.mHorizontalSpacing = horizontalSpacing; @@ -283,7 +276,7 @@ public class HTQDragGridView extends GridView { /******************** touch method ********************/ - @Override + public boolean dispatchTouchEvent(MotionEvent ev) { if (canDrag) { switch (ev.getAction()) { @@ -349,7 +342,7 @@ public class HTQDragGridView extends GridView { return super.dispatchTouchEvent(ev); } - @Override + public boolean onTouchEvent(MotionEvent ev) { if (isDrag && canDrag && mDragImageView != null) { switch (ev.getAction()) { @@ -445,7 +438,7 @@ public class HTQDragGridView extends GridView { /** * 拖动item,在里面实现了item镜像的位置更新,item的相互交换以及GridView的自行滚动 - * + * * @param moveX * @param moveY */ @@ -461,7 +454,7 @@ public class HTQDragGridView extends GridView { /** * 手指当前处于垃圾桶图标上 - * + * * @param x * @param y * @return @@ -519,7 +512,7 @@ public class HTQDragGridView extends GridView { /** * 交换item,并且控制item之间的显示与隐藏效果 - * + * * @param moveX * @param moveY */ @@ -553,7 +546,7 @@ public class HTQDragGridView extends GridView { /** * 创建移动动画 - * + * * @param view * @param startX * @param endX @@ -574,7 +567,7 @@ public class HTQDragGridView extends GridView { /** * item的交换动画效果 - * + * * @param oldPosition * @param newPosition */ diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java index f1cb526..9e13f7e 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/NoteItemCircleView.java @@ -6,8 +6,7 @@ import android.view.MotionEvent; /** * 圆形ImageView组件 点击事件不会穿透 - * - * @author kymjs(kymjs123@gmail.com) + */ public class NoteItemCircleView extends CircleImageView { diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java index ba43744..a0ec663 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/ToggleButton.java @@ -21,7 +21,7 @@ import com.example.administrator.myapplication.R; /** - * @author Qiujuer + * 开关按钮 */ public class ToggleButton extends View { /** */ @@ -320,7 +320,6 @@ public class ToggleButton extends View { /** - * @author ThinkPad */ public interface OnToggleChanged { /** diff --git a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java index e0524ad..7d5365c 100644 --- a/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java +++ b/src/MyApplication/app/src/main/java/com/example/administrator/myapplication/widget/patternlock/LockPatternView.java @@ -122,7 +122,6 @@ public class LockPatternView extends View { /** - * @author htq */ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { diff --git a/src/MyApplication/app/src/main/res/layout/activity_api_webview.xml b/src/MyApplication/app/src/main/res/layout/activity_api_webview.xml deleted file mode 100644 index 05df427..0000000 --- a/src/MyApplication/app/src/main/res/layout/activity_api_webview.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - -