diff --git a/app/build.gradle b/app/build.gradle index 29a0b7b28a..181e267ea8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -48,9 +48,9 @@ android { } release { debuggable false - minifyEnabled false - zipAlignEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + minifyEnabled true + zipAlignEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-fresco.txt' signingConfig signingConfigs.release } } @@ -102,6 +102,13 @@ dependencies { compile 'com.android.support:recyclerview-v7:23.2.1' compile 'com.android.support:appcompat-v7:23.2.1' // compile 'com.android.support:cardview-v7:21.0.0' + + // switchbutton + compile 'com.kyleduo.switchbutton:library:1.4.5' + + // systembar tint + compile 'com.readystatesoftware.systembartint:systembartint:1.0.3' + // fresco图片框架 compile 'com.facebook.fresco:fresco:0.12.0' compile 'com.facebook.fresco:animated-gif:0.12.0' diff --git a/app/proguard-fresco.txt b/app/proguard-fresco.txt new file mode 100644 index 0000000000..d1830042d0 --- /dev/null +++ b/app/proguard-fresco.txt @@ -0,0 +1,21 @@ +# Keep our interfaces so they can be used by other ProGuard rules. +# See http://sourceforge.net/p/proguard/bugs/466/ +-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip + +# Do not strip any method/class that is annotated with @DoNotStrip +-keep @com.facebook.common.internal.DoNotStrip class * +-keepclassmembers class * { + @com.facebook.common.internal.DoNotStrip *; +} + +# Keep native methods +-keepclassmembers class * { + native ; +} + +-dontwarn okio.** +-dontwarn com.squareup.okhttp.** +-dontwarn okhttp3.** +-dontwarn javax.annotation.** +-dontwarn com.android.volley.toolbox.** +-dontwarn com.facebook.infer.** \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.txt similarity index 74% rename from app/proguard-rules.pro rename to app/proguard-rules.txt index 88ca4903c2..d86dafb582 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.txt @@ -18,4 +18,13 @@ -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod -dontwarn InnerClasses --dontoptimize \ No newline at end of file +-dontoptimize + +# OrmLite uses reflection +-keep class com.j256.** +-keepclassmembers class com.j256.** { *; } +-keep enum com.j256.** +-keepclassmembers enum com.j256.** { *; } +-keep interface com.j256.** +-keepclassmembers interface com.j256.** { *; } + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5f463ee18d..23339ae398 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,368 +1,242 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/java/com/gh/base/AppController.java b/app/src/main/java/com/gh/base/AppController.java index 16bb835182..e1e88159b5 100644 --- a/app/src/main/java/com/gh/base/AppController.java +++ b/app/src/main/java/com/gh/base/AppController.java @@ -63,7 +63,7 @@ public class AppController extends Application { HttpsUtils.initHttpsUrlConnection(this); - AppUncaHandler uncaHandler = new AppUncaHandler(this); + AppUncaughtHandler uncaHandler = new AppUncaughtHandler(this); Thread.setDefaultUncaughtExceptionHandler(uncaHandler); mInstance = this; diff --git a/app/src/main/java/com/gh/base/AppUncaHandler.java b/app/src/main/java/com/gh/base/AppUncaHandler.java deleted file mode 100644 index 59cbcf35cc..0000000000 --- a/app/src/main/java/com/gh/base/AppUncaHandler.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.gh.base; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Looper; -import android.util.Log; -import android.widget.Toast; - -import com.gh.common.constant.Config; -import com.gh.common.util.DataCollectionUtils; -import com.gh.common.util.FileUtils; -import com.gh.gamecenter.SplashScreenActivity; -import com.tencent.stat.StatService; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.Thread.UncaughtExceptionHandler; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; - -public class AppUncaHandler implements UncaughtExceptionHandler { - - private UncaughtExceptionHandler mDefaultHandler; - private AppController appController; - - public AppUncaHandler(AppController appController) { - // 获取系统默认的UncaughtException处理器 - mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); - this.appController = appController; - } - - @Override - public void uncaughtException(Thread thread, Throwable ex) { - if (!handleException(ex) && mDefaultHandler != null) { - // 如果用户没有处理则让系统默认的异常处理器来处理 - mDefaultHandler.uncaughtException(thread, ex); - } else { - new Thread() { - @Override - public void run() { - Looper.prepare(); - Toast.makeText(appController.getApplicationContext(), - "\"光环助手\"发生错误", Toast.LENGTH_SHORT).show(); - Looper.loop(); - } - }.start(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - // 防止重复奔溃,导致助手一直重启,20秒内不做处理 - SharedPreferences sp = appController.getApplicationContext().getSharedPreferences( - Config.PREFERENCE, Context.MODE_PRIVATE); - long time = sp.getLong("last_restart_time", 0); - if (System.currentTimeMillis() - time > 20 * 1000) { - sp.edit().putLong("last_restart_time", System.currentTimeMillis()).apply(); - Intent intent = new Intent(appController.getApplicationContext(), - SplashScreenActivity.class); - intent.setAction(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_LAUNCHER); - PendingIntent restartIntent = PendingIntent.getActivity( - appController.getApplicationContext(), 0, intent, - PendingIntent.FLAG_UPDATE_CURRENT); - // 退出程序并重启 - AlarmManager mgr = (AlarmManager) appController - .getSystemService(Context.ALARM_SERVICE); - mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, - restartIntent); // 1秒钟后重启应用 - } - appController.finishActivity(); - } - } - - // 保存log到本地 - private void saveLog(Throwable ex) { - String errorMsg = Log.getStackTraceString(ex); - - // MTA主动上传错误 - StatService.reportError(appController.getApplicationContext(), errorMsg); - - // 上传错误数据 - DataCollectionUtils.uploadError(appController.getApplicationContext(), errorMsg); - - // 保存到本地 - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault()); - File file = new File(FileUtils.getLogPath(appController.getApplicationContext(), - format.format(new Date()) + "_gh_assist" + ".log")); - FileWriter writer = null; - try { - file.createNewFile(); - writer = new FileWriter(file); - writer.write(errorMsg); - writer.flush(); - } catch (IOException e1) { - e1.printStackTrace(); - } finally { - if (writer != null) { - try { - writer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - } - - /** - * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成. - * - * @param ex - * @return true:如果处理了该异常信息;否则返回false. - */ - private boolean handleException(Throwable ex) { - if (ex == null) { - return false; - } - saveLog(ex); - return true; - } -} \ No newline at end of file diff --git a/app/src/main/java/com/gh/base/AppUncaughtHandler.java b/app/src/main/java/com/gh/base/AppUncaughtHandler.java new file mode 100644 index 0000000000..202a5a62e4 --- /dev/null +++ b/app/src/main/java/com/gh/base/AppUncaughtHandler.java @@ -0,0 +1,125 @@ +package com.gh.base; + +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Looper; +import android.util.Log; +import android.widget.Toast; + +import com.gh.common.constant.Config; +import com.gh.common.util.DataCollectionUtils; +import com.gh.common.util.FileUtils; +import com.gh.gamecenter.SplashScreenActivity; +import com.tencent.stat.StatService; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.Thread.UncaughtExceptionHandler; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class AppUncaughtHandler implements UncaughtExceptionHandler { + + private UncaughtExceptionHandler mDefaultHandler; + private AppController mAppController; + + public AppUncaughtHandler(AppController appController) { + // 获取系统默认的UncaughtException处理器 + mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler(); + mAppController = appController; + } + + @Override + public void uncaughtException(Thread thread, Throwable ex) { + if (!handleException(ex) && mDefaultHandler != null) { + // 如果用户没有处理则让系统默认的异常处理器来处理 + mDefaultHandler.uncaughtException(thread, ex); + } else { + new Thread() { + @Override + public void run() { + Looper.prepare(); + Toast.makeText(mAppController.getApplicationContext(), + "\"光环助手\"发生错误", Toast.LENGTH_SHORT).show(); + Looper.loop(); + } + }.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + // 防止重复奔溃,导致助手一直重启,20秒内不做处理 + SharedPreferences sp = mAppController.getApplicationContext().getSharedPreferences( + Config.PREFERENCE, Context.MODE_PRIVATE); + long time = sp.getLong("last_restart_time", 0); + if (System.currentTimeMillis() - time > 20 * 1000) { + sp.edit().putLong("last_restart_time", System.currentTimeMillis()).apply(); + Intent intent = new Intent(mAppController.getApplicationContext(), SplashScreenActivity.class); + intent.setAction(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + PendingIntent restartIntent = PendingIntent.getActivity( + mAppController.getApplicationContext(), 0, intent, + PendingIntent.FLAG_UPDATE_CURRENT); + // 退出程序并重启 + AlarmManager mgr = (AlarmManager) mAppController.getSystemService(Context.ALARM_SERVICE); + mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent); // 1秒钟后重启应用 + } + mAppController.finishActivity(); + } + } + + // 保存log到本地 + private void saveLog(Throwable ex) { + String errorMsg = Log.getStackTraceString(ex); + + // MTA主动上传错误 + StatService.reportError(mAppController.getApplicationContext(), errorMsg); + + // 上传错误数据 + DataCollectionUtils.uploadError(mAppController.getApplicationContext(), errorMsg); + + // 保存到本地 + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault()); + File file = new File(FileUtils.getLogPath(mAppController.getApplicationContext(), + format.format(new Date()) + "_gh_assist" + ".log")); + FileWriter writer = null; + try { + file.createNewFile(); + writer = new FileWriter(file); + writer.write(errorMsg); + writer.flush(); + } catch (IOException e1) { + e1.printStackTrace(); + } finally { + if (writer != null) { + try { + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + } + + /** + * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成. + * + * @param ex + * @return true:如果处理了该异常信息;否则返回false. + */ + private boolean handleException(Throwable ex) { + if (ex == null) { + return false; + } + saveLog(ex); + return true; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/base/BaseActivity.java b/app/src/main/java/com/gh/base/BaseActivity.java index 052fe40093..a5867e96ba 100644 --- a/app/src/main/java/com/gh/base/BaseActivity.java +++ b/app/src/main/java/com/gh/base/BaseActivity.java @@ -6,209 +6,199 @@ import android.content.Context; import android.graphics.Color; import android.os.Build; import android.os.Bundle; -import android.view.View; +import android.view.*; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; -import android.view.Window; -import android.view.WindowManager; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; - +import android.widget.*; +import butterknife.ButterKnife; import com.gh.common.constant.Config; -import com.gh.common.util.DataUtils; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.DisplayUtils; -import com.gh.common.util.FileUtils; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.RunningUtils; -import com.gh.common.util.ShareUtils; -import com.gh.common.util.Utils; +import com.gh.common.util.*; import com.gh.download.DownloadManager; import com.gh.gamecenter.R; import com.gh.gamecenter.eventbus.EBShowDialog; import com.gh.gamecenter.listener.OnCallBackListener; -import com.gh.gamecenter.manager.SystemBarTintManager; -import com.gh.gamecenter.manager.SystemBarTintManager.SystemBarConfig; +import com.readystatesoftware.systembartint.SystemBarTintManager; +import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig; +import de.greenrobot.event.EventBus; import java.util.ArrayList; -import butterknife.ButterKnife; -import de.greenrobot.event.EventBus; +import static com.gh.common.util.EntranceUtils.KEY_DATA; +import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE; public class BaseActivity extends Activity implements OnCallBackListener { - private SystemBarTintManager tintManager; + private SystemBarTintManager mTintManager; - protected String entrance; + protected String entrance; - private boolean isPause; + private boolean isPause; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Utils.log(this.getClass().getSimpleName()); - AppController.getInstance().addActivity(this); - EventBus.getDefault().register(this); - entrance = getIntent().getStringExtra("entrance"); - if (getIntent().getBundleExtra("data") != null) { - entrance = getIntent().getBundleExtra("data").getString("entrance"); - } - } + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Utils.log(this.getClass().getSimpleName()); + AppController.getInstance().addActivity(this); + EventBus.getDefault().register(this); + entrance = getIntent().getStringExtra(KEY_ENTRANCE); + if (getIntent().getBundleExtra(KEY_DATA) != null) { + entrance = getIntent().getBundleExtra(KEY_DATA).getString(KEY_ENTRANCE); + } + } - protected void init(View contentView, String title) { - init(contentView); - TextView actionbar_tv_title = (TextView) findViewById(R.id.actionbar_tv_title); - actionbar_tv_title.setText(title); - } + protected void init(View contentView, String title) { + init(contentView); + TextView actionbar_tv_title = (TextView) findViewById(R.id.actionbar_tv_title); + actionbar_tv_title.setText(title); + } - protected void init(View contentView) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - setTheme(R.style.AppTheme); - setTranslucentStatus(true); - tintManager = new SystemBarTintManager(this); - tintManager.setStatusBarTintEnabled(true); - tintManager.setStatusBarTintColor(Color.BLACK); - SystemBarConfig config = tintManager.getConfig(); - contentView.setPadding(0, config.getPixelInsetTop(false), 0, - config.getPixelInsetBottom()); - } + protected void init(View contentView) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + setTheme(R.style.AppTheme); + setTranslucentStatus(true); + mTintManager = new SystemBarTintManager(this); + mTintManager.setStatusBarTintEnabled(true); +// mTintManager.setNavigationBarTintEnabled(true); + mTintManager.setStatusBarTintColor(Color.BLACK); + SystemBarConfig config = mTintManager.getConfig(); + contentView.setPadding(0, config.getPixelInsetTop(false), 0, + config.getPixelInsetBottom()); + } - setContentView(contentView); + setContentView(contentView); - ButterKnife.bind(this); + ButterKnife.bind(this); - int actionbar_height = getSharedPreferences(Config.PREFERENCE, - Context.MODE_PRIVATE).getInt("actionbar_height", - DisplayUtils.dip2px(getApplicationContext(), 55)); + int actionbar_height = getSharedPreferences(Config.PREFERENCE, + Context.MODE_PRIVATE).getInt("actionbar_height", + DisplayUtils.dip2px(getApplicationContext(), 55)); - RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar); - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( - LayoutParams.MATCH_PARENT, actionbar_height); - reuse_actionbar.setLayoutParams(lparams); + RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar); + LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( + LayoutParams.MATCH_PARENT, actionbar_height); + reuse_actionbar.setLayoutParams(lparams); - findViewById(R.id.actionbar_rl_back).setOnClickListener( - new OnClickListener() { - @Override - public void onClick(View v) { - finish(); - } - }); - } + findViewById(R.id.actionbar_rl_back).setOnClickListener( + new OnClickListener() { + @Override + public void onClick(View v) { + finish(); + } + }); + } - protected SystemBarTintManager getTintManager() { - return tintManager; - } + protected SystemBarTintManager getTintManager() { + return mTintManager; + } - @Override - public void finish() { - super.finish(); - AppController.getInstance().removeActivity(this); - } + @Override + public void finish() { + super.finish(); + AppController.getInstance().removeActivity(this); + } - public void toast(String msg) { - Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); - } + public void toast(String msg) { + Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); + } - public void toast(int msg) { - Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); - } + public void toast(int msg) { + Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); + } - @TargetApi(19) - protected void setTranslucentStatus(boolean status) { - Window window = getWindow(); - WindowManager.LayoutParams winParams = window.getAttributes(); - final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; - if (status) { - winParams.flags |= bits; - } else { - winParams.flags &= ~bits; - } - window.setAttributes(winParams); - } + @TargetApi(19) + protected void setTranslucentStatus(boolean status) { + Window window = getWindow(); + WindowManager.LayoutParams winParams = window.getAttributes(); + final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; + if (status) { + winParams.flags |= bits; + } else { + winParams.flags &= ~bits; + } + window.setAttributes(winParams); + } - //如果是游戏分享,newsTitle默认为空 - public void showShare(String url, String gameName, String icon, String newsTitle, ArrayList tag) { + //如果是游戏分享,newsTitle默认为空 + public void showShare(String url, String gameName, String icon, String newsTitle, ArrayList tag) { - //判断是否是官方版 - boolean isPlugin = false; - if (tag != null){ - for (String s : tag) { - if (!"官方版".equals(s)){ - isPlugin = true; - } - } - } + //判断是否是官方版 + boolean isPlugin = false; + if (tag != null) { + for (String s : tag) { + if (!"官方版".equals(s)) { + isPlugin = true; + } + } + } - ShareUtils.getInstance(this).showShareWindows(new View(this), url, gameName, icon, newsTitle, isPlugin, true); + ShareUtils.getInstance(this).showShareWindows(new View(this), url, gameName, icon, newsTitle, isPlugin, true); - if (newsTitle == null) { - DataUtils.onEvent(this, "内容分享", gameName); - } else { - DataUtils.onEvent(this, "内容分享", newsTitle); - } - } + if (newsTitle == null) { + DataUtils.onEvent(this, "内容分享", gameName); + } else { + DataUtils.onEvent(this, "内容分享", newsTitle); + } + } - public void onEventMainThread(final EBShowDialog showDialog) { - if (!isPause && this.getClass().getName().equals(RunningUtils.getTopActivity(this))) { - if ("hijack".equals(showDialog.getType())) { - DialogUtils.showQqSessionDialog(this, null);// 建议用户联系客服 - } else if ("plugin".equals(showDialog.getType())) { - DialogUtils.showPluginDialog(this, new DialogUtils.ConfiremListener(){ - @Override - public void onConfirem() { - if (FileUtils.isEmptyFile(showDialog.getPath())) { - Toast.makeText(BaseActivity.this, "解析包出错(可能被误删了),请重新下载", Toast.LENGTH_SHORT).show(); - } else { - startActivity(PackageUtils.getUninstallIntent(BaseActivity.this, showDialog.getPath())); - } - } - }); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - EventBus.getDefault().unregister(this); - } - - @Override - protected void onPause() { - super.onPause(); - DataUtils.onPause(this); - isPause = true; - } + public void onEventMainThread(final EBShowDialog showDialog) { + if (!isPause && this.getClass().getName().equals(RunningUtils.getTopActivity(this))) { + if ("hijack".equals(showDialog.getType())) { + DialogUtils.showQqSessionDialog(this, null);// 建议用户联系客服 + } else if ("plugin".equals(showDialog.getType())) { + DialogUtils.showPluginDialog(this, new DialogUtils.ConfiremListener() { + @Override + public void onConfirem() { + if (FileUtils.isEmptyFile(showDialog.getPath())) { + Toast.makeText(BaseActivity.this, "解析包出错(可能被误删了),请重新下载", Toast.LENGTH_SHORT).show(); + } else { + startActivity(PackageUtils.getUninstallIntent(BaseActivity.this, showDialog.getPath())); + } + } + }); + } + } + } - @Override - protected void onResume() { - super.onResume(); - DataUtils.onResume(this); - isPause = false; - DownloadManager.getInstance(this).initGameMap(); - } + @Override + protected void onDestroy() { + super.onDestroy(); + EventBus.getDefault().unregister(this); + } - @Override - public void loadDone() { - - } + @Override + protected void onPause() { + super.onPause(); + DataUtils.onPause(this); + isPause = true; + } - @Override - public void loadDone(Object obj) { + @Override + protected void onResume() { + super.onResume(); + DataUtils.onResume(this); + isPause = false; + DownloadManager.getInstance(this).initGameMap(); + } - } + @Override + public void loadDone() { - @Override - public void loadError() { + } - } + @Override + public void loadDone(Object obj) { - @Override - public void loadEmpty() { + } - } + @Override + public void loadError() { + + } + + @Override + public void loadEmpty() { + + } } diff --git a/app/src/main/java/com/gh/base/BaseFragmentActivity.java b/app/src/main/java/com/gh/base/BaseFragmentActivity.java index 6b8aa4ae89..67f9bb75fd 100644 --- a/app/src/main/java/com/gh/base/BaseFragmentActivity.java +++ b/app/src/main/java/com/gh/base/BaseFragmentActivity.java @@ -6,36 +6,22 @@ import android.graphics.Color; import android.os.Build; import android.os.Bundle; import android.support.v4.app.FragmentActivity; -import android.view.View; +import android.view.*; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; -import android.view.Window; -import android.view.WindowManager; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.Toast; - +import android.widget.*; +import butterknife.ButterKnife; import com.gh.common.constant.Config; -import com.gh.common.util.DataUtils; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.DisplayUtils; -import com.gh.common.util.FileUtils; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.RunningUtils; -import com.gh.common.util.ShareUtils; -import com.gh.common.util.Utils; +import com.gh.common.util.*; import com.gh.download.DownloadManager; import com.gh.gamecenter.R; import com.gh.gamecenter.eventbus.EBShowDialog; -import com.gh.gamecenter.manager.SystemBarTintManager; -import com.gh.gamecenter.manager.SystemBarTintManager.SystemBarConfig; +import com.readystatesoftware.systembartint.SystemBarTintManager; +import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig; +import de.greenrobot.event.EventBus; import java.util.ArrayList; -import butterknife.ButterKnife; -import de.greenrobot.event.EventBus; - public class BaseFragmentActivity extends FragmentActivity { protected String entrance; diff --git a/app/src/main/java/com/gh/base/GHPushMessageReceiver.java b/app/src/main/java/com/gh/base/GHPushMessageReceiver.java index f590fb2503..979bb1231f 100644 --- a/app/src/main/java/com/gh/base/GHPushMessageReceiver.java +++ b/app/src/main/java/com/gh/base/GHPushMessageReceiver.java @@ -1,8 +1,6 @@ package com.gh.base; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; +import android.app.*; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; @@ -15,31 +13,16 @@ import android.support.v4.util.ArrayMap; import android.text.TextUtils; import android.util.Log; import android.widget.RemoteViews; - -import com.gh.common.util.ClassUtils; -import com.gh.common.util.FileUtils; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.RunningUtils; -import com.gh.common.util.TokenUtils; -import com.gh.common.util.Utils; +import com.gh.common.util.*; import com.gh.gamecenter.R; -import com.gh.gamecenter.SplashScreenActivity; -import com.xiaomi.mipush.sdk.ErrorCode; -import com.xiaomi.mipush.sdk.MiPushClient; -import com.xiaomi.mipush.sdk.MiPushCommandMessage; -import com.xiaomi.mipush.sdk.MiPushMessage; -import com.xiaomi.mipush.sdk.PushMessageReceiver; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; +import com.xiaomi.mipush.sdk.*; +import org.json.*; import java.io.File; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Locale; +import java.util.*; + +import static com.gh.common.util.EntranceUtils.*; /** * 1、PushMessageReceiver是个抽象类,该类继承了BroadcastReceiver。 @@ -78,7 +61,7 @@ public class GHPushMessageReceiver extends PushMessageReceiver { // 1判断渠道号是否一致或是否为ALL String TD_CHANNEL_ID = (String) PackageUtils.getMetaData(context, context.getPackageName(), "TD_CHANNEL_ID"); if ("ALL".equals(channel) || channel.equalsIgnoreCase(TD_CHANNEL_ID)) { - String type = jsonObject.getString("type"); + String type = jsonObject.getString(KEY_TYPE); Utils.log("type = " + type); if ("NEWS".equals(type)) { // 新闻推送 @@ -245,42 +228,23 @@ public class GHPushMessageReceiver extends PushMessageReceiver { String content = message.getContent(); JSONObject response = new JSONObject(content); Bundle bundle = new Bundle(); - bundle.putString("entrance", "(小米推送)"); - String type = response.getString("type"); - if ("article".equals(type)) { - bundle.putString("to", "NewsDetailActivity"); - bundle.putString("newsId", response.getString("target")); - } else if ("game".equals(type)) { - bundle.putString("to", "GameDetailActivity"); - bundle.putString("gameId", response.getString("target")); - } else if ("column".equals(type)) { - bundle.putString("to", "SubjectActivity"); - bundle.putString("id", response.getString("target")); - } else if ("web".equals(type)) { - bundle.putString("to", "WebActivity"); - bundle.putString("url", response.getString("target")); - } - if (RunningUtils.isRunning(context)) { - // 应用正在运行,前台或后台 - String to = bundle.getString("to"); - if (!TextUtils.isEmpty(to)) { - Class clazz = ClassUtils.forName(to); - if (clazz != null) { - Intent intent1 = new Intent(context, clazz); - intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent1.putExtra("data", bundle); - context.startActivity(intent1); - } - } - } else { - // 应用未在运行 - Intent intent1 = new Intent(context, SplashScreenActivity.class); - intent1.setAction(Intent.ACTION_MAIN); - intent1.addCategory(Intent.CATEGORY_LAUNCHER); - intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent1.putExtra("data", bundle); - context.startActivity(intent1); + bundle.putString(KEY_ENTRANCE, ENTRANCE_MIPUSH); + String type = response.getString(KEY_TYPE); + String target = response.getString(KEY_TARGET); + if (HOST_ARTICLE.equals(type)) { + bundle.putString(KEY_TO, "NewsDetailActivity"); + bundle.putString(KEY_NEWSID, target); + } else if (HOST_GAME.equals(type)) { + bundle.putString(KEY_TO, "GameDetailActivity"); + bundle.putString(KEY_GAMEID, target); + } else if (HOSt_COLUMN.equals(type)) { + bundle.putString(KEY_TO, "SubjectActivity"); + bundle.putString(KEY_ID, target); + } else if (HOST_WEB.equals(type)) { + bundle.putString(KEY_TO, "WebActivity"); + bundle.putString(KEY_URL, target); } + EntranceUtils.jumpActivity(context, bundle); } catch (JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java b/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java index 45bbb7d8bd..5a9f4397e8 100644 --- a/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java +++ b/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java @@ -1,14 +1,9 @@ package com.gh.base; import android.content.Context; -import android.content.Intent; import android.os.Bundle; -import android.text.TextUtils; -import com.gh.common.util.ClassUtils; -import com.gh.common.util.RunningUtils; -import com.gh.gamecenter.MainActivity; -import com.gh.gamecenter.SplashScreenActivity; +import com.gh.common.util.*; import com.umeng.message.UmengNotificationClickHandler; import com.umeng.message.entity.UMessage; @@ -23,46 +18,26 @@ public class GHUmengNotificationClickHandler extends UmengNotificationClickHandl // super.launchApp(context, uMessage); try { - String content = uMessage.extra.get("data"); + String content = uMessage.extra.get(EntranceUtils.KEY_DATA); JSONObject response = new JSONObject(content); Bundle bundle = new Bundle(); - bundle.putString("entrance", "(友盟推送)"); - String type = response.getString("type"); - if ("article".equals(type)) { - bundle.putString("to", "NewsDetailActivity"); - bundle.putString("newsId", response.getString("target")); - } else if ("game".equals(type)) { - bundle.putString("to", "GameDetailActivity"); - bundle.putString("gameId", response.getString("target")); - } else if ("column".equals(type)) { - bundle.putString("to", "SubjectActivity"); - bundle.putString("id", response.getString("target")); - } else if ("web".equals(type)) { - bundle.putString("to", "WebActivity"); - bundle.putString("url", response.getString("target")); - } - if (RunningUtils.isRunning(context) - && MainActivity.class.getName().equals(RunningUtils.getBaseActivity(context))) { - // 应用正在运行,前台或后台 - String to = bundle.getString("to"); - if (!TextUtils.isEmpty(to)) { - Class clazz = ClassUtils.forName(to); - if (clazz != null) { - Intent intent1 = new Intent(context, clazz); - intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent1.putExtra("data", bundle); - context.startActivity(intent1); - } - } - } else { - // 应用未在运行 - Intent intent1 = new Intent(context, SplashScreenActivity.class); - intent1.setAction(Intent.ACTION_MAIN); - intent1.addCategory(Intent.CATEGORY_LAUNCHER); - intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent1.putExtra("data", bundle); - context.startActivity(intent1); + bundle.putString(EntranceUtils.KEY_ENTRANCE, EntranceUtils.ENTRANCE_UMENG); + String type = response.getString(EntranceUtils.KEY_TYPE); + String target = response.getString(EntranceUtils.KEY_TARGET); + if (EntranceUtils.HOST_ARTICLE.equals(type)) { + bundle.putString(EntranceUtils.KEY_TO, "NewsDetailActivity"); + bundle.putString(EntranceUtils.KEY_NEWSID, target); + } else if (EntranceUtils.HOST_GAME.equals(type)) { + bundle.putString(EntranceUtils.KEY_TO, "GameDetailActivity"); + bundle.putString(EntranceUtils.KEY_GAMEID, target); + } else if (EntranceUtils.HOSt_COLUMN.equals(type)) { + bundle.putString(EntranceUtils.KEY_TO, "SubjectActivity"); + bundle.putString(EntranceUtils.KEY_ID, target); + } else if (EntranceUtils.HOST_WEB.equals(type)) { + bundle.putString(EntranceUtils.KEY_TO, "WebActivity"); + bundle.putString(EntranceUtils.KEY_URL, target); } + EntranceUtils.jumpActivity(context, bundle); } catch (JSONException e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/gh/common/util/EntranceUtils.java b/app/src/main/java/com/gh/common/util/EntranceUtils.java new file mode 100644 index 0000000000..260376c40e --- /dev/null +++ b/app/src/main/java/com/gh/common/util/EntranceUtils.java @@ -0,0 +1,73 @@ +package com.gh.common.util; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; +import com.gh.gamecenter.MainActivity; +import com.gh.gamecenter.SplashScreenActivity; + +/** + * @author CsHeng + * @Date 2017/4/25 + * @Time 16:39 + */ + +public class EntranceUtils { + + public static final String KEY_TO = "to"; + public static final String KEY_NEWSID = "newsId"; + public static final String KEY_GAMEID = "gameId"; + public static final String KEY_ID = "id"; + public static final String KEY_URL = "url"; + public static final String HOST_ARTICLE = "article"; + public static final String HOST_GAME = "game"; + public static final String HOSt_COLUMN = "column"; + public static final String HOST_WEB = "web"; + public static final String HOST_DOWNLOAD = "download"; + public static final String HOST_SUGGESTION = "suggestion"; + public static final String KEY_DATA = "data"; + public static final String KEY_TYPE = "type"; + public static final String KEY_NAME = "name"; + public static final String KEY_ENTRANCE = "entrance"; + public static final String KEY_TARGET = "target"; + public static final String ENTRANCE_BROWSER = "(浏览器)"; + public static final String ENTRANCE_UMENG = "(友盟推送)"; + public static final String ENTRANCE_MIPUSH = "(小米推送)"; + public static final String ENTRANCE_DOWNLOAD = "(下载跳转)"; + public static final String KEY_SUGGEST_HINT_TYPE = "suggestHintType"; + public static final String KEY_PACKAGENAME = "packageName"; + public static final String KEY_PLATFORM = "platform"; + public static final String KEY_GAME_NAME = "game_name"; + public static final String KEY_VERSION = "version"; + public static final String KEY_CONTENT = "content"; + public static final String KEY_PLUGIN = "plugin"; + public static final String KEY_CURRENT_ITEM = "currentItem"; + + public static void jumpActivity(Context context, Bundle bundle) { + + //TODO 把其他类似的跳转启动逻辑也处理掉 + if (RunningUtils.isRunning(context) + && MainActivity.class.getName().equals(RunningUtils.getBaseActivity(context))) { + // 应用正在运行,前台或后台 + String to = bundle.getString(KEY_TO); + if (!TextUtils.isEmpty(to)) { + Class clazz = ClassUtils.forName(to); + if (clazz != null) { + Intent intent1 = new Intent(context, clazz); + intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent1.putExtra(KEY_DATA, bundle); + context.startActivity(intent1); + } + } + } else { + // 应用未在运行 + Intent intent1 = new Intent(context, SplashScreenActivity.class); + intent1.setAction(Intent.ACTION_MAIN); + intent1.addCategory(Intent.CATEGORY_LAUNCHER); + intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent1.putExtra(KEY_DATA, bundle); + context.startActivity(intent1); + } + } +} diff --git a/app/src/main/java/com/gh/common/util/RunningUtils.java b/app/src/main/java/com/gh/common/util/RunningUtils.java index 53efa19e20..a7b1925e29 100644 --- a/app/src/main/java/com/gh/common/util/RunningUtils.java +++ b/app/src/main/java/com/gh/common/util/RunningUtils.java @@ -5,123 +5,137 @@ import android.app.ActivityManager.RunningAppProcessInfo; import android.app.ActivityManager.RunningTaskInfo; import android.content.ComponentName; import android.content.Context; +import android.os.Looper; import java.util.List; public class RunningUtils { - /** - * 判断当前应用程序处于前台还是后台 - */ - public static boolean isApplicationBroughtToBackground(Context context) { - ActivityManager am = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List tasks = am.getRunningTasks(1); - if (!tasks.isEmpty()) { - ComponentName topActivity = tasks.get(0).topActivity; - if (!topActivity.getPackageName().equals(context.getPackageName())) { - return true; - } - } - return false; + /** + * 判断当前应用程序处于前台还是后台 + */ + public static boolean isApplicationBroughtToBackground(Context context) { + ActivityManager am = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List tasks = am.getRunningTasks(1); + if (!tasks.isEmpty()) { + ComponentName topActivity = tasks.get(0).topActivity; + if (!topActivity.getPackageName().equals(context.getPackageName())) { + return true; + } + } + return false; - } + } - /** - * 判断当前应用程序处于前台还是后台 - */ - public static boolean isBackground(Context context) { - ActivityManager activityManager = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List appProcesses = activityManager - .getRunningAppProcesses(); - for (RunningAppProcessInfo appProcess : appProcesses) { - if (appProcess.processName.equals(context.getPackageName())) { - if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) { - return true; - } else { - return false; - } - } - } - return false; - } + /** + * 判断当前应用程序处于前台还是后台 + */ + public static boolean isBackground(Context context) { + ActivityManager activityManager = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List appProcesses = activityManager + .getRunningAppProcesses(); + for (RunningAppProcessInfo appProcess : appProcesses) { + if (appProcess.processName.equals(context.getPackageName())) { + if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND) { + return true; + } else { + return false; + } + } + } + return false; + } - /** - * 判断当前topactivity是否与传入的相同 - */ - public static boolean isEqualsTop(Context context, String activityName) { - ActivityManager activityManager = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List infos = activityManager.getRunningTasks(100); - for (RunningTaskInfo info : infos) { - if (info.topActivity.getClassName().equals(activityName)) { - return true; - } - } - return false; - } - - /** - * 判断当前baseActivity是否与传入的相同 - */ - public static boolean isEqualsBase(Context context, String activityName) { - ActivityManager activityManager = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List infos = activityManager.getRunningTasks(100); - for (RunningTaskInfo info : infos) { - if (info.baseActivity.getClassName().equals(activityName)) { - return true; - } - } - return false; - } - - /** - * 判断应用是否正在运行 - */ - public static boolean isRunning(Context context) { - ActivityManager activityManager = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List infos = activityManager.getRunningTasks(100); - for (RunningTaskInfo info : infos) { - if (info.topActivity.getPackageName().equals(context.getPackageName()) - && info.baseActivity.getPackageName().equals(context.getPackageName())) { - return true; - } - } - return false; - } + /** + * 判断当前topactivity是否与传入的相同 + */ + public static boolean isEqualsTop(Context context, String activityName) { + ActivityManager activityManager = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List infos = activityManager.getRunningTasks(100); + for (RunningTaskInfo info : infos) { + if (info.topActivity.getClassName().equals(activityName)) { + return true; + } + } + return false; + } - /** - * 获取当前baseActivity - */ - public static String getBaseActivity(Context context) { - ActivityManager activityManager = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List infos = activityManager.getRunningTasks(100); - for (RunningTaskInfo info : infos) { - if (info.baseActivity.getPackageName().equals(context.getPackageName())) { - return info.baseActivity.getClassName(); - } - } - return null; - } + /** + * 判断当前baseActivity是否与传入的相同 + */ + public static boolean isEqualsBase(Context context, String activityName) { + ActivityManager activityManager = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List infos = activityManager.getRunningTasks(100); + for (RunningTaskInfo info : infos) { + if (info.baseActivity.getClassName().equals(activityName)) { + return true; + } + } + return false; + } - /** - * 获取当前topActivity - */ - public static String getTopActivity(Context context) { - ActivityManager activityManager = (ActivityManager) context - .getSystemService(Context.ACTIVITY_SERVICE); - List infos = activityManager.getRunningTasks(100); - for (RunningTaskInfo info : infos) { - if (info.topActivity.getPackageName().equals( - context.getPackageName())) { - return info.topActivity.getClassName(); - } - } - return null; - } + /** + * 判断应用是否正在运行 + */ + public static boolean isRunning(Context context) { + ActivityManager activityManager = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List infos = activityManager.getRunningTasks(100); + for (RunningTaskInfo info : infos) { + if (info.topActivity.getPackageName().equals(context.getPackageName()) + && info.baseActivity.getPackageName().equals(context.getPackageName())) { + return true; + } + } + return false; + } + + /** + * 获取当前baseActivity + */ + public static String getBaseActivity(Context context) { + ActivityManager activityManager = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List infos = activityManager.getRunningTasks(100); + for (RunningTaskInfo info : infos) { + if (info.baseActivity.getPackageName().equals(context.getPackageName())) { + return info.baseActivity.getClassName(); + } + } + return null; + } + + /** + * 获取当前topActivity + */ + public static String getTopActivity(Context context) { + ActivityManager activityManager = (ActivityManager) context + .getSystemService(Context.ACTIVITY_SERVICE); + List infos = activityManager.getRunningTasks(100); + for (RunningTaskInfo info : infos) { + if (info.topActivity.getPackageName().equals( + context.getPackageName())) { + return info.topActivity.getClassName(); + } + } + return null; + } + + public static boolean isInUiThread() { + return Looper.myLooper() == Looper.getMainLooper(); + } + + //TODO 未经测试代码 + public static void runOnUI(Context context, Runnable runnable) { + if (isInUiThread()) { + Looper.prepare(); + runnable.run(); + Looper.loop(); + } + } } diff --git a/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java b/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java index 702aa50d42..4e224c6ebe 100644 --- a/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ChooseReceiverActivity.java @@ -1,58 +1,31 @@ package com.gh.gamecenter; import android.animation.Animator; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; +import android.app.Activity; +import android.content.*; import android.graphics.Color; import android.net.wifi.ScanResult; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; +import android.os.*; import android.text.Html; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.AccelerateInterpolator; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.ScaleAnimation; -import android.view.animation.TranslateAnimation; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; - +import android.view.*; +import android.view.animation.*; +import android.widget.*; +import butterknife.BindView; +import butterknife.OnClick; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.interfaces.DraweeController; import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.AppController; import com.gh.base.BaseActivity; import com.gh.common.constant.Config; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.DisplayUtils; -import com.gh.common.util.UserIconUtils; -import com.gh.common.util.Utils; -import com.gh.gamecenter.kuaichuan.BaseTransfer; -import com.gh.gamecenter.kuaichuan.Constant; -import com.gh.gamecenter.kuaichuan.FileInfo; -import com.gh.gamecenter.kuaichuan.HotspotManager; -import com.gh.gamecenter.kuaichuan.WifiMgr; -import com.gh.gamecenter.kuaichuan.WifiUtils; -import com.gh.gamecenter.manager.SystemBarTintManager; - +import com.gh.common.util.*; +import com.gh.gamecenter.kuaichuan.*; +import com.readystatesoftware.systembartint.SystemBarTintManager; import org.json.JSONObject; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import butterknife.BindView; -import butterknife.OnClick; +import java.lang.ref.WeakReference; +import java.net.*; +import java.util.*; /** * Created by khy on 2017/1/20. @@ -102,20 +75,33 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick private TranslateAnimation mTranslateAnimation; // 整个火箭移动页面 - Handler handler = new Handler() { + private Handler handler = new MyHandler(this); + + static class MyHandler extends Handler { + + private WeakReference mActivityWeakReference; + + MyHandler(Activity activity){ + mActivityWeakReference = new WeakReference<>(activity); + } + @Override public void handleMessage(Message msg) { super.handleMessage(msg); - if (msg.what == 0 && !isStopScan) { - updateWifiScanResult(); - handler.sendEmptyMessageDelayed(0, 2000); - } else if (msg.what == 2) { - isStopScan = false; - handler.sendEmptyMessage(0); - connFailedAnimView(); + + ChooseReceiverActivity activity = (ChooseReceiverActivity) mActivityWeakReference.get(); + if ( activity!=null){ + if (msg.what == 0 && !activity.isStopScan) { + activity.updateWifiScanResult(); + sendEmptyMessageDelayed(0, 2000); + } else if (msg.what == 2) { + activity.isStopScan = false; + sendEmptyMessage(0); + activity.connFailedAnimView(); + } } } - }; + } @Override protected void onCreate(Bundle savedInstanceState) { @@ -417,7 +403,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick String response = new String(receivePacket.getData(), 0, receivePacket.getLength()).trim(); Utils.log("ChooseReceiverActivity:: 接收UDP请求" + response); - if(response != null && response.contains(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS)) { + if(response.contains(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS)) { JSONObject jsonObject = new JSONObject(response); Utils.log("ChooseReceiverActivity:: 收到UDP请求::SUCCESS=" + jsonObject.getString(Constant.MSG_FILE_RECEIVER_INIT_SUCCESS)); @@ -440,9 +426,11 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick } private void sendFileInfoListToFileReceiverWithUdp(int serverPort, InetAddress ipAddress) { - List fileInfos = (List) AppController.get("FileInfo", false); - - for (FileInfo fileInfo : fileInfos) { + List fileInfoList = (List) AppController.get("FileInfo", false); + if (fileInfoList == null) { + return; + } + for (FileInfo fileInfo : fileInfoList) { String fileInfoJson = FileInfo.toJsonStr(fileInfo); Utils.log("ChooseReceiverActivity:: 发送的文件列表::" + fileInfoJson); DatagramPacket sendFileInfoListPacket = @@ -549,7 +537,7 @@ public class ChooseReceiverActivity extends BaseActivity implements View.OnClick private void connFailedAnimView() { mActionbar.setVisibility(View.VISIBLE); Utils.toast(ChooseReceiverActivity.this, "连接失败"); - if (mScaleAnimation == null) { + if (mScaleAnimation != null) { mScaleAnimation.cancel(); } mRoketRl.animate() diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index 8dbeb3401a..391b0321d1 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -1,97 +1,40 @@ package com.gh.gamecenter; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; +import android.content.*; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.graphics.Color; import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.SystemClock; +import android.os.*; import android.provider.Settings; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; import android.support.v4.util.ArrayMap; -import android.text.Html; -import android.text.Spanned; -import android.text.TextUtils; +import android.text.*; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.TextView; - +import android.widget.*; import com.gh.base.BaseFragmentActivity; import com.gh.common.constant.Config; -import com.gh.common.util.ClassUtils; -import com.gh.common.util.DataCollectionUtils; -import com.gh.common.util.DataLogUtils; -import com.gh.common.util.DataUtils; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.FileUtils; -import com.gh.common.util.GameUtils; -import com.gh.common.util.LibaoUtils; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.PlatformUtils; -import com.gh.common.util.TokenUtils; -import com.gh.common.util.TrafficUtils; -import com.gh.common.util.Utils; -import com.gh.download.DataWatcher; -import com.gh.download.DownloadEntity; -import com.gh.download.DownloadManager; -import com.gh.download.DownloadStatus; +import com.gh.common.util.*; +import com.gh.download.*; import com.gh.gamecenter.db.MessageMarkReadDao; -import com.gh.gamecenter.db.info.ConcernInfo; -import com.gh.gamecenter.db.info.GameInfo; -import com.gh.gamecenter.db.info.MessageMarkReadInfo; -import com.gh.gamecenter.entity.ApkEntity; -import com.gh.gamecenter.entity.GameDigestEntity; -import com.gh.gamecenter.entity.GameEntity; -import com.gh.gamecenter.entity.GameUpdateEntity; -import com.gh.gamecenter.entity.SuggestionTypeEntity; -import com.gh.gamecenter.eventbus.EBDownloadStatus; -import com.gh.gamecenter.eventbus.EBPackage; -import com.gh.gamecenter.eventbus.EBShowDialog; -import com.gh.gamecenter.eventbus.EBSkip; -import com.gh.gamecenter.eventbus.EBUISwitch; +import com.gh.gamecenter.db.info.*; +import com.gh.gamecenter.entity.*; +import com.gh.gamecenter.eventbus.*; import com.gh.gamecenter.game.GameFragment; -import com.gh.gamecenter.manager.ConcernManager; -import com.gh.gamecenter.manager.DataCollectionManager; -import com.gh.gamecenter.manager.FilterManager; -import com.gh.gamecenter.manager.GameManager; -import com.gh.gamecenter.manager.PackageManager; -import com.gh.gamecenter.manager.UpdateManager; +import com.gh.gamecenter.manager.*; import com.gh.gamecenter.message.MessageFragment; import com.gh.gamecenter.news.NewsFragment; import com.gh.gamecenter.personal.PersonalFragment; -import com.gh.gamecenter.retrofit.JSONObjectResponse; -import com.gh.gamecenter.retrofit.ObservableUtil; +import com.gh.gamecenter.retrofit.*; import com.gh.gamecenter.retrofit.Response; -import com.gh.gamecenter.retrofit.RetrofitManager; - +import de.greenrobot.event.EventBus; +import okhttp3.*; import org.json.JSONArray; import org.json.JSONObject; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import de.greenrobot.event.EventBus; -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.ResponseBody; import retrofit2.adapter.rxjava.HttpException; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; @@ -99,6 +42,12 @@ import rx.functions.Action1; import rx.functions.Func1; import rx.schedulers.Schedulers; +import java.io.IOException; +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + /** * 项目的主Activity,3个Fragment都嵌入在这里。 */ @@ -377,14 +326,14 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene @Override public void run() { // 注册设备 - TokenUtils.register(MainActivity.this); - TokenUtils.getToken(MainActivity.this, false) + TokenUtils.register(MainActivity.this.getApplicationContext()); + TokenUtils.getToken(MainActivity.this.getApplicationContext(), false) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { @Override public void onResponse(String token) { - TokenUtils.checkDeviceInfo(MainActivity.this, token); + TokenUtils.checkDeviceInfo(MainActivity.this.getApplicationContext(), token); } }); updateUserGhzs(); diff --git a/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java b/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java index 28fee291bc..af29d54542 100644 --- a/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ReceiverWaitingActivity.java @@ -1,53 +1,31 @@ package com.gh.gamecenter; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.SharedPreferences; +import android.app.Activity; +import android.content.*; import android.graphics.Color; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; +import android.os.*; import android.text.Html; import android.text.TextUtils; -import android.view.Gravity; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; - +import android.view.*; +import android.widget.*; +import butterknife.BindView; import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.AppController; import com.gh.base.BaseActivity; import com.gh.common.constant.Config; -import com.gh.common.util.DialogUtils; -import com.gh.common.util.DisplayUtils; -import com.gh.common.util.RandomUtils; -import com.gh.common.util.UserIconUtils; -import com.gh.common.util.Utils; +import com.gh.common.util.*; import com.gh.common.view.RadarLayout; -import com.gh.gamecenter.kuaichuan.BaseTransfer; -import com.gh.gamecenter.kuaichuan.Constant; -import com.gh.gamecenter.kuaichuan.FileInfo; -import com.gh.gamecenter.kuaichuan.HotspotManager; -import com.gh.gamecenter.kuaichuan.IpPortInfo; -import com.gh.gamecenter.kuaichuan.WifiMgr; -import com.gh.gamecenter.manager.SystemBarTintManager; +import com.gh.gamecenter.kuaichuan.*; import com.gh.gamecenter.receiver.WifiAPBroadcastReceiver; - +import com.readystatesoftware.systembartint.SystemBarTintManager; import org.json.JSONObject; import java.io.Serializable; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.InetSocketAddress; +import java.lang.ref.WeakReference; +import java.net.*; import java.util.ArrayList; import java.util.List; -import butterknife.BindView; - /** * Created by khy on 2017/1/20. */ @@ -81,35 +59,47 @@ public class ReceiverWaitingActivity extends BaseActivity { /** * 与 文件发送方 通信的 线程 */ - Runnable mUdpServerRuannable; + private Runnable mUdpServerRunnable; + + private Handler mHandler = new MyHandler(this); + + static class MyHandler extends Handler { + private WeakReference mActivityWeakReference; + MyHandler(Activity activity){ + mActivityWeakReference = new WeakReference<>(activity); + } - Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg) { - if(msg.what == 0){ - if (mFileInfos.size() == 0) { - Utils.toast(ReceiverWaitingActivity.this, "接收异常::ReceiverWaitingActivity"); - return; + super.handleMessage(msg); + + ReceiverWaitingActivity activity = (ReceiverWaitingActivity) mActivityWeakReference.get(); + if (activity != null) { + if (msg.what == 0) { + if (activity.mFileInfos.size() == 0) { + Utils.toast(activity, "接收异常::ReceiverWaitingActivity"); + return; + } + ArrayList list = new ArrayList<>(); + list.addAll(activity.mFileInfos); + IpPortInfo ipPortInfo = (IpPortInfo) msg.obj; + Bundle bundle = new Bundle(); + bundle.putSerializable(Constant.KEY_IP_PORT_INFO, ipPortInfo); + bundle.putSerializable(Constant.KEY_IP_FILE_INFO, (Serializable) activity.mFileInfos); + bundle.putParcelableArrayList(Constant.KEY_IP_FILE_INFO, list); + bundle.putBoolean("isOpenWifi", activity.isOpenWifi); + + Intent intent = new Intent(activity, FileReceiverActivity.class); + intent.putExtras(bundle); + activity.startActivity(intent); + + activity.colsePage(); + } else if (msg.what == 1) { + activity.mNoConnHint.setVisibility(View.VISIBLE); } - ArrayList list = new ArrayList(); - list.add(mFileInfos); - IpPortInfo ipPortInfo = (IpPortInfo) msg.obj; - Bundle bundle = new Bundle(); - bundle.putSerializable(Constant.KEY_IP_PORT_INFO, ipPortInfo); - bundle.putSerializable(Constant.KEY_IP_FILE_INFO, (Serializable) mFileInfos); - bundle.putParcelableArrayList(Constant.KEY_IP_FILE_INFO, list); - bundle.putBoolean("isOpenWifi", isOpenWifi); - - Intent intent = new Intent(ReceiverWaitingActivity.this, FileReceiverActivity.class); - intent.putExtras(bundle); - startActivity(intent); - - colsePage(); - } else if (msg.what == 1) { - mNoConnHint.setVisibility(View.VISIBLE); } } - }; + } @Override protected void onCreate(Bundle savedInstanceState) { @@ -171,8 +161,8 @@ public class ReceiverWaitingActivity extends BaseActivity { @Override public void onWifiApEnabled() { if(!mIsInitialized) { - mUdpServerRuannable = createSendMsgToFileSenderRunnable(); - AppController.MAIN_EXECUTOR.execute(mUdpServerRuannable); + mUdpServerRunnable = createSendMsgToFileSenderRunnable(); + AppController.MAIN_EXECUTOR.execute(mUdpServerRunnable); mIsInitialized = true; mWaitingConn.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/com/gh/gamecenter/SearchActivity.java b/app/src/main/java/com/gh/gamecenter/SearchActivity.java index 877915850f..64c69b799c 100644 --- a/app/src/main/java/com/gh/gamecenter/SearchActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SearchActivity.java @@ -2,36 +2,25 @@ package com.gh.gamecenter; import android.app.ActionBar.LayoutParams; import android.content.Context; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; +import android.os.*; import android.support.v4.app.FragmentTransaction; -import android.text.Editable; -import android.text.TextUtils; -import android.text.TextWatcher; +import android.text.*; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; +import android.widget.*; import android.widget.TextView.OnEditorActionListener; - import com.gh.base.BaseFragmentActivity; import com.gh.common.constant.Config; import com.gh.common.util.DataCollectionUtils; import com.gh.common.util.DisplayUtils; import com.gh.gamecenter.db.SearchHistoryDao; import com.gh.gamecenter.eventbus.EBSearch; -import com.gh.gamecenter.manager.SystemBarTintManager; -import com.gh.gamecenter.manager.SystemBarTintManager.SystemBarConfig; -import com.gh.gamecenter.search.SearchGameDetailFragment; -import com.gh.gamecenter.search.SearchGameListFragment; -import com.gh.gamecenter.search.SearchHistoryFragment; +import com.gh.gamecenter.search.*; +import com.readystatesoftware.systembartint.SystemBarTintManager; +import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig; public class SearchActivity extends BaseFragmentActivity { diff --git a/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java b/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java index 2612e655ed..34b795b2ca 100644 --- a/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ShareCardActivity.java @@ -8,23 +8,16 @@ import android.os.Handler; import android.text.Html; import android.text.TextUtils; import android.view.View; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; - +import android.widget.*; +import butterknife.BindView; import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.BaseActivity; -import com.gh.common.util.ImageUtils; -import com.gh.common.util.MessageShareUtils; -import com.gh.common.util.QRCodeUtils; -import com.gh.gamecenter.manager.SystemBarTintManager; +import com.gh.common.util.*; +import com.readystatesoftware.systembartint.SystemBarTintManager; import com.tencent.tauth.Tencent; import java.io.File; -import butterknife.BindView; - /** * Created by khy on 2016/11/7. * 分享卡片 diff --git a/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java b/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java index e3a387ad77..b537a72804 100644 --- a/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java +++ b/app/src/main/java/com/gh/gamecenter/ShareCardPicActivity.java @@ -1,21 +1,16 @@ package com.gh.gamecenter; import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; +import android.graphics.*; import android.graphics.drawable.Animatable; import android.os.Bundle; import android.text.Html; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.ScrollView; -import android.widget.TextView; - +import android.widget.*; +import butterknife.BindView; +import butterknife.OnClick; import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.controller.BaseControllerListener; import com.facebook.drawee.controller.ControllerListener; @@ -23,12 +18,11 @@ import com.facebook.drawee.interfaces.DraweeController; import com.facebook.drawee.view.SimpleDraweeView; import com.facebook.imagepipeline.image.ImageInfo; import com.gh.base.BaseActivity; -import com.gh.common.util.ImageUtils; -import com.gh.common.util.MessageShareUtils; -import com.gh.common.util.QRCodeUtils; -import com.gh.gamecenter.manager.SystemBarTintManager; +import com.gh.common.util.*; import com.gh.gamecenter.retrofit.ObservableUtil; +import com.readystatesoftware.systembartint.SystemBarTintManager; import com.tencent.tauth.Tencent; +import rx.functions.Action1; import java.io.File; import java.io.IOException; @@ -38,10 +32,6 @@ import java.util.List; import java.util.Vector; import java.util.concurrent.CountDownLatch; -import butterknife.BindView; -import butterknife.OnClick; -import rx.functions.Action1; - /** * Created by khy on 2016/11/7. */ @@ -101,7 +91,7 @@ public class ShareCardPicActivity extends BaseActivity { View contentView = View.inflate(this, R.layout.activity_sharecard_pic, null); init(contentView, "分享卡片"); - shareArrImg = new Vector<>();; + shareArrImg = new Vector<>(); shareArrImg.addAll(arrImg); mActionbar.setBackgroundColor(getResources().getColor(R.color.back)); @@ -166,16 +156,15 @@ public class ShareCardPicActivity extends BaseActivity { } private void setContentImage(String url){ - ControllerListener listener = new BaseControllerListener(){ + ControllerListener listener = new BaseControllerListener(){ @Override - public void onFinalImageSet(String id, Object imageInfo, Animatable animatable) { + public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { super.onFinalImageSet(id, imageInfo, animatable); if (imageInfo == null){ return; } - ImageInfo imageInfo1 = (ImageInfo) imageInfo; - int height = imageInfo1.getHeight(); - int width = imageInfo1.getWidth(); + int height = imageInfo.getHeight(); + int width = imageInfo.getWidth(); float index = (float) height / (float) width; ViewGroup.LayoutParams layoutParams = mShareContentImgRv.getLayoutParams(); int widthPixels = getResources().getDisplayMetrics().widthPixels; @@ -187,26 +176,6 @@ public class ShareCardPicActivity extends BaseActivity { } mShareContentImgRv.setLayoutParams(layoutParams); } - - @Override - public void onIntermediateImageSet(String id, Object imageInfo) { - super.onIntermediateImageSet(id, imageInfo); - } - - @Override - public void onIntermediateImageFailed(String id, Throwable throwable) { - super.onIntermediateImageFailed(id, throwable); - } - - @Override - public void onFailure(String id, Throwable throwable) { - super.onFailure(id, throwable); - } - - @Override - public void onRelease(String id) { - super.onRelease(id); - } }; DraweeController controller = Fresco.newDraweeControllerBuilder() diff --git a/app/src/main/java/com/gh/gamecenter/SkipActivity.java b/app/src/main/java/com/gh/gamecenter/SkipActivity.java index c4125fe114..ddcf12c5c3 100644 --- a/app/src/main/java/com/gh/gamecenter/SkipActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SkipActivity.java @@ -4,89 +4,114 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; - import com.gh.base.BaseActivity; import com.gh.common.util.PlatformUtils; import com.gh.common.util.RunningUtils; +import static com.gh.common.util.EntranceUtils.*; + /** * Created by LGT on 2016/11/16. * 链接跳转用 */ public class SkipActivity extends BaseActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); - if (getIntent() != null) { - String host = getIntent().getData().getHost(); - String id = getIntent().getData().getPath(); - if (!TextUtils.isEmpty(id)) { - id = id.substring(1); - } - Intent intent = new Intent(); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra("entrance", "(浏览器)"); - if (RunningUtils.isRunning(this) - && MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) { - // 应用正在运行,前台或后台 - if ("article".equals(host)) { - intent.setClass(this, NewsDetailActivity.class); - intent.putExtra("newsId", id); - } else if ("game".equals(host)) { - intent.setClass(this, GameDetailActivity.class); - intent.putExtra("gameId", id); - } else if ("column".equals(host)) { - intent.setClass(this, SubjectActivity.class); - intent.putExtra("id", id); - intent.putExtra("name", getIntent().getData().getQueryParameter("name")); - } else if ("suggestion".equals(host)) { - Uri uri = getIntent().getData(); - String content = "【" + uri.getQueryParameter("game_name") - + "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform")) - + "-V" + uri.getQueryParameter("version") + "】"; - intent.putExtra("content", content); - intent.putExtra("suggestHintType", "plugin"); - intent.setClass(this, SuggestionActivity.class); - } else if ("download".equals(host)) { - intent.setClass(this, DownloadManagerActivity.class); - intent.putExtra("gameId", id); - intent.putExtra("packageName", getIntent().getData().getQueryParameter("packageName")); - } - } else { - // 应用未在运行 - intent.setClass(this, SplashScreenActivity.class); - intent.setAction(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_LAUNCHER); + if (getIntent() != null) { + String host = getIntent().getData().getHost(); + String id = getIntent().getData().getPath(); + if (!TextUtils.isEmpty(id)) { + id = id.substring(1); + } + Intent intent = new Intent(); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra(KEY_ENTRANCE, ENTRANCE_BROWSER); - if ("article".equals(host)) { - intent.putExtra("newsId", id); - intent.putExtra("to", "NewsDetailActivity"); - } else if ("game".equals(host)) { - intent.putExtra("gameId", id); - intent.putExtra("to", "GameDetailActivity"); - } else if ("column".equals(host)) { - intent.putExtra("to", "SubjectActivity"); - intent.putExtra("id", id); - intent.putExtra("name", getIntent().getData().getQueryParameter("name")); - } else if ("suggestion".equals(host)) { - Uri uri = getIntent().getData(); - String content = "【" + uri.getQueryParameter("game_name") - + "-" + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter("platform")) - + "-V" + uri.getQueryParameter("version") + "】"; - intent.putExtra("content", content); - intent.putExtra("to", "SuggestionActivity"); - } else if ("download".equals(host)) { - intent.putExtra("to", "DownloadManagerActivity"); - intent.putExtra("gameId", id); - intent.putExtra("packageName", getIntent().getData().getQueryParameter("packageName")); - } - } - startActivity(intent); - } - finish(); + if (RunningUtils.isRunning(this) + && MainActivity.class.getName().equals(RunningUtils.getBaseActivity(this))) { + // 应用正在运行,前台或后台 - } + if (host != null) { + switch (host) { + case HOST_ARTICLE: + intent.setClass(this, NewsDetailActivity.class); + intent.putExtra(KEY_NEWSID, id); + break; + case HOST_GAME: + intent.setClass(this, GameDetailActivity.class); + intent.putExtra(KEY_GAMEID, id); + break; + case HOSt_COLUMN: + intent.setClass(this, SubjectActivity.class); + intent.putExtra(KEY_ID, id); + intent.putExtra(KEY_NAME, getIntent().getData().getQueryParameter(KEY_NAME)); + break; + case HOST_SUGGESTION: + Uri uri = getIntent().getData(); + + String content = String.format("【%s-%s-V%s】", + uri.getQueryParameter(KEY_GAME_NAME), + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter(KEY_PLATFORM)), + uri.getQueryParameter(KEY_VERSION)); + intent.putExtra(KEY_CONTENT, content); + intent.putExtra(KEY_SUGGEST_HINT_TYPE, KEY_PLUGIN); + intent.setClass(this, SuggestionActivity.class); + break; + case HOST_DOWNLOAD: + intent.setClass(this, DownloadManagerActivity.class); + intent.putExtra(KEY_GAMEID, id); + intent.putExtra(KEY_PACKAGENAME, getIntent().getData().getQueryParameter(KEY_PACKAGENAME)); + break; + } + } + + } else { + // 应用未在运行 + intent.setClass(this, SplashScreenActivity.class); + intent.setAction(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + + if (host != null) { + + switch (host) { + case HOST_ARTICLE: + intent.putExtra(KEY_NEWSID, id); + intent.putExtra(KEY_TO, "NewsDetailActivity"); + break; + case HOST_GAME: + intent.putExtra(KEY_NEWSID, id); + intent.putExtra(KEY_TO, "GameDetailActivity"); + break; + case HOSt_COLUMN: + intent.putExtra(KEY_TO, "SubjectActivity"); + intent.putExtra(KEY_ID, id); + intent.putExtra(KEY_NAME, getIntent().getData().getQueryParameter(KEY_NAME)); + break; + case HOST_SUGGESTION: + Uri uri = getIntent().getData(); + String content = String.format("【%s-%s-V%s】", + uri.getQueryParameter(KEY_GAME_NAME), + PlatformUtils.getInstance(this).getPlatformName(uri.getQueryParameter(KEY_PLATFORM)), + uri.getQueryParameter(KEY_VERSION)); + intent.putExtra(KEY_CONTENT, content); + intent.putExtra(KEY_TO, "SuggestionActivity"); + break; + case HOST_DOWNLOAD: + intent.putExtra(KEY_TO, "DownloadManagerActivity"); + intent.putExtra(KEY_GAMEID, id); + intent.putExtra(KEY_PACKAGENAME, getIntent().getData().getQueryParameter(KEY_PACKAGENAME)); + break; + + } + } + } + startActivity(intent); + } + finish(); + + } } diff --git a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java index 4af20f01f3..bcbe1385ac 100644 --- a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java @@ -2,31 +2,18 @@ package com.gh.gamecenter; import android.app.ActionBar; import android.app.ActionBar.LayoutParams; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; +import android.content.*; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.os.Handler; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.util.DisplayMetrics; -import android.view.KeyEvent; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; - +import android.view.*; +import android.widget.*; import com.gh.base.BaseActivity; import com.gh.common.constant.Config; -import com.gh.common.util.FileUtils; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.PlatformUtils; -import com.gh.common.util.TagUtils; -import com.gh.common.util.TimestampUtils; -import com.gh.common.util.TokenUtils; -import com.gh.common.util.Utils; +import com.gh.common.util.*; import com.gh.download.DownloadManager; import com.gh.download.DownloadService; import com.gh.gamecenter.eventbus.EBReuse; @@ -34,18 +21,18 @@ import com.gh.gamecenter.manager.DataCollectionManager; import com.gh.gamecenter.manager.FilterManager; import com.gh.gamecenter.retrofit.JSONObjectResponse; import com.gh.gamecenter.retrofit.RetrofitManager; - +import de.greenrobot.event.EventBus; import org.json.JSONException; import org.json.JSONObject; +import rx.android.schedulers.AndroidSchedulers; +import rx.schedulers.Schedulers; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -import de.greenrobot.event.EventBus; -import rx.android.schedulers.AndroidSchedulers; -import rx.schedulers.Schedulers; +import static com.gh.common.util.EntranceUtils.KEY_DATA; /** * 引导页面 @@ -318,15 +305,16 @@ public class SplashScreenActivity extends BaseActivity { }); } + // 跳转到主界面 private void launch() { Bundle bundle = getIntent().getExtras(); - if (getIntent().getBundleExtra("data") != null) { - bundle = getIntent().getBundleExtra("data"); + if (getIntent().getBundleExtra(KEY_DATA) != null) { + bundle = getIntent().getBundleExtra(KEY_DATA); } Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class); - intent.putExtra("data", bundle); + intent.putExtra(KEY_DATA, bundle); startActivity(intent); finish(); } diff --git a/app/src/main/java/com/gh/gamecenter/kuaichuan/FileInfo.java b/app/src/main/java/com/gh/gamecenter/kuaichuan/FileInfo.java index e46e1cab9b..73573b6cfa 100644 --- a/app/src/main/java/com/gh/gamecenter/kuaichuan/FileInfo.java +++ b/app/src/main/java/com/gh/gamecenter/kuaichuan/FileInfo.java @@ -1,7 +1,8 @@ package com.gh.gamecenter.kuaichuan; import android.graphics.Bitmap; - +import android.os.Parcel; +import android.os.Parcelable; import org.json.JSONException; import org.json.JSONObject; @@ -10,7 +11,7 @@ import java.io.Serializable; /** * Created by khy on 2017/1/20. */ -public class FileInfo implements Serializable { +public class FileInfo implements Parcelable, Serializable { /** * 文件传输的标识 @@ -173,4 +174,43 @@ public class FileInfo implements Serializable { return fileInfo; } + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(this.filePath); + dest.writeLong(this.size); + dest.writeString(this.name); + dest.writeParcelable(this.bitmap, flags); + dest.writeString(this.fileTag); + dest.writeInt(this.result); + dest.writeLong(this.progress); + dest.writeString(this.packageName); + } + + protected FileInfo(Parcel in) { + this.filePath = in.readString(); + this.size = in.readLong(); + this.name = in.readString(); + this.bitmap = in.readParcelable(Bitmap.class.getClassLoader()); + this.fileTag = in.readString(); + this.result = in.readInt(); + this.progress = in.readLong(); + this.packageName = in.readString(); + } + + public static final Creator CREATOR = new Creator() { + @Override + public FileInfo createFromParcel(Parcel source) { + return new FileInfo(source); + } + + @Override + public FileInfo[] newArray(int size) { + return new FileInfo[size]; + } + }; } diff --git a/app/src/main/java/com/gh/gamecenter/manager/SystemBarTintManager.java b/app/src/main/java/com/gh/gamecenter/manager/SystemBarTintManager.java deleted file mode 100644 index e71d4c6dbf..0000000000 --- a/app/src/main/java/com/gh/gamecenter/manager/SystemBarTintManager.java +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (C) 2013 readyState Software Ltd - * - * 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 - * - * http://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.gh.gamecenter.manager; - -import android.annotation.SuppressLint; -import android.annotation.TargetApi; -import android.app.Activity; -import android.content.Context; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; -import android.os.Build; -import android.util.DisplayMetrics; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.View; -import android.view.ViewConfiguration; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.FrameLayout.LayoutParams; - -import java.lang.reflect.Method; - -/** - * Class to manage status and navigation bar tint effects when using KitKat - * translucent system UI modes. - * - */ -public class SystemBarTintManager { - - static { - // Android allows a system property to override the presence of the - // navigation bar. - // Used by the emulator. - // See - // https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - try { - Class c = Class.forName("android.os.SystemProperties"); - Method m = c.getDeclaredMethod("get", String.class); - m.setAccessible(true); - sNavBarOverride = (String) m.invoke(null, "qemu.hw.mainkeys"); - } catch (Throwable e) { - sNavBarOverride = null; - } - } - } - - /** - * The default system bar tint color value. - */ - public static final int DEFAULT_TINT_COLOR = 0x99000000; - - private static String sNavBarOverride; - - private final SystemBarConfig mConfig; - private boolean mStatusBarAvailable; - private boolean mNavBarAvailable; - private boolean mStatusBarTintEnabled; - private boolean mNavBarTintEnabled; - private View mStatusBarTintView; - private View mNavBarTintView; - - /** - * Constructor. Call this in the host activity onCreate method after its - * content view has been set. You should always create new instances when - * the host activity is recreated. - * - * @param activity - * The host activity. - */ - @TargetApi(19) - public SystemBarTintManager(Activity activity) { - - Window win = activity.getWindow(); - ViewGroup decorViewGroup = (ViewGroup) win.getDecorView(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - // check theme attrs - int[] attrs = { android.R.attr.windowTranslucentStatus, - android.R.attr.windowTranslucentNavigation }; - TypedArray a = activity.obtainStyledAttributes(attrs); - try { - mStatusBarAvailable = a.getBoolean(0, false); - mNavBarAvailable = a.getBoolean(1, false); - } finally { - a.recycle(); - } - - // check window flags - WindowManager.LayoutParams winParams = win.getAttributes(); - int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; - if ((winParams.flags & bits) != 0) { - mStatusBarAvailable = true; - } - bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; - if ((winParams.flags & bits) != 0) { - mNavBarAvailable = true; - } - } - - mConfig = new SystemBarConfig(activity, mStatusBarAvailable, - mNavBarAvailable); - // device might not have virtual navigation keys - if (!mConfig.hasNavigtionBar()) { - mNavBarAvailable = false; - } - - if (mStatusBarAvailable) { - setupStatusBarView(activity, decorViewGroup); - } - if (mNavBarAvailable) { - setupNavBarView(activity, decorViewGroup); - } - - } - - /** - * Enable tinting of the system status bar. - * - * If the platform is running Jelly Bean or earlier, or translucent system - * UI modes have not been enabled in either the theme or via window flags, - * then this method does nothing. - * - * @param enabled - * True to enable tinting, false to disable it (default). - */ - public void setStatusBarTintEnabled(boolean enabled) { - mStatusBarTintEnabled = enabled; - if (mStatusBarAvailable) { - mStatusBarTintView - .setVisibility(enabled ? View.VISIBLE : View.GONE); - } - } - - /** - * Enable tinting of the system navigation bar. - * - * If the platform does not have soft navigation keys, is running Jelly Bean - * or earlier, or translucent system UI modes have not been enabled in - * either the theme or via window flags, then this method does nothing. - * - * @param enabled - * True to enable tinting, false to disable it (default). - */ - public void setNavigationBarTintEnabled(boolean enabled) { - mNavBarTintEnabled = enabled; - if (mNavBarAvailable) { - mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE); - } - } - - /** - * Apply the specified color tint to all system UI bars. - * - * @param color - * The color of the background tint. - */ - public void setTintColor(int color) { - setStatusBarTintColor(color); - setNavigationBarTintColor(color); - } - - /** - * Apply the specified drawable or color resource to all system UI bars. - * - * @param res - * The identifier of the resource. - */ - public void setTintResource(int res) { - setStatusBarTintResource(res); - setNavigationBarTintResource(res); - } - - /** - * Apply the specified drawable to all system UI bars. - * - * @param drawable - * The drawable to use as the background, or null to remove it. - */ - public void setTintDrawable(Drawable drawable) { - setStatusBarTintDrawable(drawable); - setNavigationBarTintDrawable(drawable); - } - - /** - * Apply the specified alpha to all system UI bars. - * - * @param alpha - * The alpha to use - */ - public void setTintAlpha(float alpha) { - setStatusBarAlpha(alpha); - setNavigationBarAlpha(alpha); - } - - /** - * Apply the specified color tint to the system status bar. - * - * @param color - * The color of the background tint. - */ - public void setStatusBarTintColor(int color) { - if (mStatusBarAvailable) { - mStatusBarTintView.setBackgroundColor(color); - } - } - - /** - * Apply the specified drawable or color resource to the system status bar. - * - * @param res - * The identifier of the resource. - */ - public void setStatusBarTintResource(int res) { - if (mStatusBarAvailable) { - mStatusBarTintView.setBackgroundResource(res); - } - } - - /** - * Apply the specified drawable to the system status bar. - * - * @param drawable - * The drawable to use as the background, or null to remove it. - */ - @SuppressWarnings("deprecation") - public void setStatusBarTintDrawable(Drawable drawable) { - if (mStatusBarAvailable) { - mStatusBarTintView.setBackgroundDrawable(drawable); - } - } - - /** - * Apply the specified alpha to the system status bar. - * - * @param alpha - * The alpha to use - */ - @TargetApi(11) - public void setStatusBarAlpha(float alpha) { - if (mStatusBarAvailable - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - mStatusBarTintView.setAlpha(alpha); - } - } - - /** - * Apply the specified color tint to the system navigation bar. - * - * @param color - * The color of the background tint. - */ - public void setNavigationBarTintColor(int color) { - if (mNavBarAvailable) { - mNavBarTintView.setBackgroundColor(color); - } - } - - /** - * Apply the specified drawable or color resource to the system navigation - * bar. - * - * @param res - * The identifier of the resource. - */ - public void setNavigationBarTintResource(int res) { - if (mNavBarAvailable) { - mNavBarTintView.setBackgroundResource(res); - } - } - - /** - * Apply the specified drawable to the system navigation bar. - * - * @param drawable - * The drawable to use as the background, or null to remove it. - */ - @SuppressWarnings("deprecation") - public void setNavigationBarTintDrawable(Drawable drawable) { - if (mNavBarAvailable) { - mNavBarTintView.setBackgroundDrawable(drawable); - } - } - - /** - * Apply the specified alpha to the system navigation bar. - * - * @param alpha - * The alpha to use - */ - @TargetApi(11) - public void setNavigationBarAlpha(float alpha) { - if (mNavBarAvailable - && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - mNavBarTintView.setAlpha(alpha); - } - } - - /** - * Get the system bar configuration. - * - * @return The system bar configuration for the current device - * configuration. - */ - public SystemBarConfig getConfig() { - return mConfig; - } - - /** - * Is tinting enabled for the system status bar? - * - * @return True if enabled, False otherwise. - */ - public boolean isStatusBarTintEnabled() { - return mStatusBarTintEnabled; - } - - /** - * Is tinting enabled for the system navigation bar? - * - * @return True if enabled, False otherwise. - */ - public boolean isNavBarTintEnabled() { - return mNavBarTintEnabled; - } - - private void setupStatusBarView(Context context, ViewGroup decorViewGroup) { - mStatusBarTintView = new View(context); - LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, - mConfig.getStatusBarHeight()); - params.gravity = Gravity.TOP; - if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) { - params.rightMargin = mConfig.getNavigationBarWidth(); - } - mStatusBarTintView.setLayoutParams(params); - mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR); - mStatusBarTintView.setVisibility(View.GONE); - decorViewGroup.addView(mStatusBarTintView); - } - - private void setupNavBarView(Context context, ViewGroup decorViewGroup) { - mNavBarTintView = new View(context); - LayoutParams params; - if (mConfig.isNavigationAtBottom()) { - params = new LayoutParams(LayoutParams.MATCH_PARENT, - mConfig.getNavigationBarHeight()); - params.gravity = Gravity.BOTTOM; - } else { - params = new LayoutParams(mConfig.getNavigationBarWidth(), - LayoutParams.MATCH_PARENT); - params.gravity = Gravity.RIGHT; - } - mNavBarTintView.setLayoutParams(params); - mNavBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR); - mNavBarTintView.setVisibility(View.GONE); - decorViewGroup.addView(mNavBarTintView); - } - - /** - * Class which describes system bar sizing and other characteristics for the - * current device configuration. - * - */ - public static class SystemBarConfig { - - private static final String STATUS_BAR_HEIGHT_RES_NAME = "status_bar_height"; - private static final String NAV_BAR_HEIGHT_RES_NAME = "navigation_bar_height"; - private static final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = "navigation_bar_height_landscape"; - private static final String NAV_BAR_WIDTH_RES_NAME = "navigation_bar_width"; - private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar"; - - private final boolean mTranslucentStatusBar; - private final boolean mTranslucentNavBar; - private final int mStatusBarHeight; - private final int mActionBarHeight; - private final boolean mHasNavigationBar; - private final int mNavigationBarHeight; - private final int mNavigationBarWidth; - private final boolean mInPortrait; - private final float mSmallestWidthDp; - - private SystemBarConfig(Activity activity, - boolean translucentStatusBar, boolean traslucentNavBar) { - Resources res = activity.getResources(); - mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); - mSmallestWidthDp = getSmallestWidthDp(activity); - mStatusBarHeight = getInternalDimensionSize(res, - STATUS_BAR_HEIGHT_RES_NAME); - mActionBarHeight = getActionBarHeight(activity); - mNavigationBarHeight = getNavigationBarHeight(activity); - mNavigationBarWidth = getNavigationBarWidth(activity); - mHasNavigationBar = (mNavigationBarHeight > 0); - mTranslucentStatusBar = translucentStatusBar; - mTranslucentNavBar = traslucentNavBar; - } - - @TargetApi(14) - private int getActionBarHeight(Context context) { - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - TypedValue tv = new TypedValue(); - context.getTheme().resolveAttribute( - android.R.attr.actionBarSize, tv, true); - result = TypedValue.complexToDimensionPixelSize(tv.data, - context.getResources().getDisplayMetrics()); - } - return result; - } - - @TargetApi(14) - private int getNavigationBarHeight(Context context) { - Resources res = context.getResources(); - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - if (hasNavBar(context)) { - String key; - if (mInPortrait) { - key = NAV_BAR_HEIGHT_RES_NAME; - } else { - key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME; - } - return getInternalDimensionSize(res, key); - } - } - return result; - } - - @TargetApi(14) - private int getNavigationBarWidth(Context context) { - Resources res = context.getResources(); - int result = 0; - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - if (hasNavBar(context)) { - return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME); - } - } - return result; - } - - @TargetApi(14) - private boolean hasNavBar(Context context) { - Resources res = context.getResources(); - int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", - "android"); - if (resourceId != 0) { - boolean hasNav = res.getBoolean(resourceId); - // check override flag (see static block) - if ("1".equals(sNavBarOverride)) { - hasNav = false; - } else if ("0".equals(sNavBarOverride)) { - hasNav = true; - } - return hasNav; - } else { // fallback - return !ViewConfiguration.get(context).hasPermanentMenuKey(); - } - } - - private int getInternalDimensionSize(Resources res, String key) { - int result = 0; - int resourceId = res.getIdentifier(key, "dimen", "android"); - if (resourceId > 0) { - result = res.getDimensionPixelSize(resourceId); - } - return result; - } - - @SuppressLint("NewApi") - private float getSmallestWidthDp(Activity activity) { - DisplayMetrics metrics = new DisplayMetrics(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - activity.getWindowManager().getDefaultDisplay() - .getRealMetrics(metrics); - } else { - // TODO this is not correct, but we don't really care pre-kitkat - activity.getWindowManager().getDefaultDisplay() - .getMetrics(metrics); - } - float widthDp = metrics.widthPixels / metrics.density; - float heightDp = metrics.heightPixels / metrics.density; - return Math.min(widthDp, heightDp); - } - - /** - * Should a navigation bar appear at the bottom of the screen in the - * current device configuration? A navigation bar may appear on the - * right side of the screen in certain configurations. - * - * @return True if navigation should appear at the bottom of the screen, - * False otherwise. - */ - public boolean isNavigationAtBottom() { - return (mSmallestWidthDp >= 600 || mInPortrait); - } - - /** - * Get the height of the system status bar. - * - * @return The height of the status bar (in pixels). - */ - public int getStatusBarHeight() { - return mStatusBarHeight; - } - - /** - * Get the height of the action bar. - * - * @return The height of the action bar (in pixels). - */ - public int getActionBarHeight() { - return mActionBarHeight; - } - - /** - * Does this device have a system navigation bar? - * - * @return True if this device uses soft key navigation, False - * otherwise. - */ - public boolean hasNavigtionBar() { - return mHasNavigationBar; - } - - /** - * Get the height of the system navigation bar. - * - * @return The height of the navigation bar (in pixels). If the device - * does not have soft navigation keys, this will always return - * 0. - */ - public int getNavigationBarHeight() { - return mNavigationBarHeight; - } - - /** - * Get the width of the system navigation bar when it is placed - * vertically on the screen. - * - * @return The width of the navigation bar (in pixels). If the device - * does not have soft navigation keys, this will always return - * 0. - */ - public int getNavigationBarWidth() { - return mNavigationBarWidth; - } - - /** - * Get the layout inset for any system UI that appears at the top of the - * screen. - * - * @param withActionBar - * True to include the height of the action bar, False - * otherwise. - * @return The layout inset (in pixels). - */ - public int getPixelInsetTop(boolean withActionBar) { - return (mTranslucentStatusBar ? mStatusBarHeight : 0) - + (withActionBar ? mActionBarHeight : 0); - } - - /** - * Get the layout inset for any system UI that appears at the bottom of - * the screen. - * - * @return The layout inset (in pixels). - */ - public int getPixelInsetBottom() { - if (mTranslucentNavBar && isNavigationAtBottom()) { - return mNavigationBarHeight; - } else { - return 0; - } - } - - /** - * Get the layout inset for any system UI that appears at the right of - * the screen. - * - * @return The layout inset (in pixels). - */ - public int getPixelInsetRight() { - if (mTranslucentNavBar && !isNavigationAtBottom()) { - return mNavigationBarWidth; - } else { - return 0; - } - } - - } - -} diff --git a/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java b/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java index 90605b687e..03629f5ff4 100644 --- a/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java +++ b/app/src/main/java/com/gh/gamecenter/receiver/DownloadReceiver.java @@ -5,6 +5,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import com.gh.common.util.EntranceUtils; import com.gh.common.util.RunningUtils; import com.gh.gamecenter.DownloadManagerActivity; import com.gh.gamecenter.SplashScreenActivity; @@ -12,6 +13,10 @@ import com.gh.gamecenter.eventbus.EBSkip; import de.greenrobot.event.EventBus; +import static com.gh.common.util.EntranceUtils.ENTRANCE_DOWNLOAD; +import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE; +import static com.gh.common.util.EntranceUtils.KEY_TO; + /** * Created by LGT on 2016/10/10. * notification下载跳转 @@ -40,8 +45,8 @@ public class DownloadReceiver extends BroadcastReceiver { } else { Intent intent2 = new Intent(context, DownloadManagerActivity.class); intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent2.putExtra("entrance", "(下载跳转)"); - intent2.putExtra("currentItem", 1); + intent2.putExtra(KEY_ENTRANCE, ENTRANCE_DOWNLOAD); + intent2.putExtra(EntranceUtils.KEY_CURRENT_ITEM, 1); context.startActivity(intent2); } } else { @@ -49,9 +54,9 @@ public class DownloadReceiver extends BroadcastReceiver { Intent intent2 = new Intent(context, SplashScreenActivity.class); intent2.setAction(Intent.ACTION_MAIN); intent2.addCategory(Intent.CATEGORY_LAUNCHER); - intent2.putExtra("to", "DownloadManagerActivity"); - intent2.putExtra("currentItem", 1); - intent2.putExtra("entrance", "(下载跳转)"); + intent2.putExtra(KEY_TO, "DownloadManagerActivity"); + intent2.putExtra(EntranceUtils.KEY_CURRENT_ITEM, 1); + intent2.putExtra(KEY_ENTRANCE, ENTRANCE_DOWNLOAD); intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent2); } diff --git a/app/src/main/java/com/gh/gamecenter/receiver/NotificationReceiver.java b/app/src/main/java/com/gh/gamecenter/receiver/NotificationReceiver.java index 2e4339fe0a..187d29f6ef 100644 --- a/app/src/main/java/com/gh/gamecenter/receiver/NotificationReceiver.java +++ b/app/src/main/java/com/gh/gamecenter/receiver/NotificationReceiver.java @@ -1,31 +1,19 @@ package com.gh.gamecenter.receiver; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; +import android.content.*; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.support.v4.util.ArrayMap; - import com.gh.base.AppController; -import com.gh.common.util.GameUtils; -import com.gh.common.util.PackageUtils; -import com.gh.common.util.RunningUtils; -import com.gh.gamecenter.DownloadManagerActivity; -import com.gh.gamecenter.NewsDetailActivity; -import com.gh.gamecenter.SplashScreenActivity; +import com.gh.common.util.*; +import com.gh.gamecenter.*; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.eventbus.EBMiPush; import com.google.gson.Gson; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.ArrayList; -import java.util.List; - import de.greenrobot.event.EventBus; +import org.json.*; + +import java.util.*; /** * 用于接收点击小米推送的notification的广播 @@ -45,8 +33,8 @@ public class NotificationReceiver extends BroadcastReceiver { if (RunningUtils.isRunning(context)) { // 应用正在运行,前台或后台 Intent intent1 = new Intent(context, NewsDetailActivity.class); - intent1.putExtra("newsId", jsonObject.get("_id").toString()); - intent1.putExtra("entrance", "(小米推送)"); + intent1.putExtra(EntranceUtils.KEY_NEWSID, jsonObject.get("_id").toString()); + intent1.putExtra(EntranceUtils.KEY_ENTRANCE, EntranceUtils.ENTRANCE_MIPUSH); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1); } else { @@ -54,9 +42,9 @@ public class NotificationReceiver extends BroadcastReceiver { Intent intent1 = new Intent(context, SplashScreenActivity.class); intent1.setAction(Intent.ACTION_MAIN); intent1.addCategory(Intent.CATEGORY_LAUNCHER); - intent1.putExtra("to", "NewsDetailActivity"); - intent1.putExtra("newsId", jsonObject.get("_id").toString()); - intent1.putExtra("entrance", "(小米推送)"); + intent1.putExtra(EntranceUtils.KEY_TO, "NewsDetailActivity"); + intent1.putExtra(EntranceUtils.KEY_NEWSID, jsonObject.get("_id").toString()); + intent1.putExtra(EntranceUtils.KEY_ENTRANCE, EntranceUtils.ENTRANCE_MIPUSH); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent1); } @@ -120,10 +108,11 @@ public class NotificationReceiver extends BroadcastReceiver { case 2: String tag = jsonObject.getString("tag"); String[] tags = tag.split(","); - JSONArray array = new JSONArray(); - for (int i = 0; i < tags.length; i++) { - array.put(tags[i]); - } +// JSONArray array = new JSONArray(); +// for (int i = 0; i < tags.length; i++) { +// array.put(tags[i]); +// } + JSONArray array = new JSONArray(Arrays.asList(tags)); jsonObject.put("tag", array); if (RunningUtils.isRunning(context)) { // 应用正在运行,前台或后台 diff --git a/app/src/main/java/com/kyleduo/switchbutton/AnimationController.java b/app/src/main/java/com/kyleduo/switchbutton/AnimationController.java deleted file mode 100644 index 0a7c0cc2af..0000000000 --- a/app/src/main/java/com/kyleduo/switchbutton/AnimationController.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.kyleduo.switchbutton; - -import android.os.Handler; -import android.os.Message; - -/** - * controller of view animation - * - * @author kyleduo - * @since 2014-09-25 - * - */ -class AnimationController { - - private static int ANI_WHAT = 0x100; - private static int DEFAULT_VELOCITY = 7; - private static int DEFAULT_FRAME_DURATION = 1000 / 60; - - private AnimationHandler mHandler; - private OnAnimateListener mOnAnimateListener; - - private boolean isAnimating = false; - - private int mFrame, mFrom, mTo; - private int mVelocity = DEFAULT_VELOCITY; - - private AnimationController() { - mHandler = new AnimationHandler(); - } - - /** - * get default AnimationController - * @return - */ - static AnimationController getDefault() { - AnimationController ac = new AnimationController(); - return ac; - } - - /** - * initial an AnimationController with a listener - * @param onAnimateListener NOT NULL - * @return - */ - AnimationController init(OnAnimateListener onAnimateListener) { - if (onAnimateListener == null) { - throw new IllegalArgumentException("onAnimateListener can not be null"); - } - this.mOnAnimateListener = onAnimateListener; - return this; - } - - private static class AnimationHandler extends Handler { - @Override - public void handleMessage(Message msg) { - if (msg.what == ANI_WHAT) { - if (msg.obj != null) { - ((Runnable) msg.obj).run(); - } - } - } - } - - void startAnimation(int from, int to) { - this.isAnimating = true; - this.mFrom = from; - this.mTo = to; - this.mFrame = mVelocity; - if (mTo > mFrom) { - this.mFrame = Math.abs(this.mVelocity); - } else if (mTo < mFrom) { - this.mFrame = -Math.abs(this.mVelocity); - } else { - this.isAnimating = false; - this.mOnAnimateListener.onAnimateComplete(); - return; - } - this.mOnAnimateListener.onAnimationStart(); - new RequireNextFrame().run(); - } - - void stopAnimation() { - isAnimating = false; - } - - /** - * configure the velocity of animation - * @param velocity a positive number - */ - public void setVelocity(int velocity) { - if (velocity <= 0) { - mVelocity = DEFAULT_VELOCITY; - return; - } - mVelocity = velocity; - } - - /** - * calculate next frame in child thread - * - * @author kyleduo - * - */ - class RequireNextFrame implements Runnable { - @Override - public void run() { - if (!isAnimating) { - return; - } - calcNextFrame(); - mOnAnimateListener.onFrameUpdate(mFrame); - if (mOnAnimateListener.continueAnimating()) { - requireNextFrame(); - } else { - stopAnimation(); - mOnAnimateListener.onAnimateComplete(); - return; - } - } - - private void calcNextFrame() { -// mFrame = mVelocity; - } - - private void requireNextFrame() { - Message msg = mHandler.obtainMessage(); - msg.what = ANI_WHAT; - msg.obj = this; - mHandler.sendMessageDelayed(msg, DEFAULT_FRAME_DURATION); - } - } - - /** - * interface for view animation - * - * @author kyle - * - */ - interface OnAnimateListener { - /** - * invoked when the animation start - */ - public void onAnimationStart(); - - /** - * ask view whether continue Animating - * - * @return boolean true for continueAnimating - */ - public boolean continueAnimating(); - - /** - * a new frame is ready. - * - * @param frame next step of the animation, for linear animation, it is equal to velocity - */ - public void onFrameUpdate(int frame); - - /** - * invoked when the animation complete - */ - public void onAnimateComplete(); - } -} diff --git a/app/src/main/java/com/kyleduo/switchbutton/Configuration.java b/app/src/main/java/com/kyleduo/switchbutton/Configuration.java deleted file mode 100644 index 8eeec3ec14..0000000000 --- a/app/src/main/java/com/kyleduo/switchbutton/Configuration.java +++ /dev/null @@ -1,407 +0,0 @@ -package com.kyleduo.switchbutton; - -import android.graphics.Color; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.StateListDrawable; -import android.view.View; - -import java.lang.reflect.Field; - -/** - * class for configuring the Switchbutton - * used when you want to change the face of this view in code - * - * @author kyleduo - * @since 2014-09-24 - */ -public class Configuration implements Cloneable { - - static class Default { - static int DEFAULT_OFF_COLOR = Color.parseColor("#B3B3B3");//B3B3B3、E3E3E3 - static int DEFAULT_ON_COLOR = Color.parseColor("#00B7FA");//00B7FA、02BFE7 - static int DEFAULT_THUMB_COLOR = Color.parseColor("#FFFFFF"); - static int DEFAULT_THUMB_PRESSED_COLOR = Color.parseColor("#fafafa"); - static int DEFAULT_THUMB_MARGIN = 2; - static int DEFAULT_RADIUS = 999; - static float DEFAULT_MEASURE_FACTOR = 2f; - static int DEFAULT_INNER_BOUNDS = 0; - } - - static class Limit { - static int MIN_THUMB_SIZE = 24; - } - - /** - * drawable of background - */ - private Drawable mOnDrawable = null, mOffDrawable = null; - /** - * drawable of thumb - */ - private Drawable mThumbDrawable = null; - - private int mOnColor = Default.DEFAULT_ON_COLOR, mOffColor = Default.DEFAULT_OFF_COLOR, mThumbColor = Default.DEFAULT_THUMB_COLOR, mThumbPressedColor = Default.DEFAULT_THUMB_PRESSED_COLOR; - - /** - * space between View's border and thumb - */ - private int mThumbMarginTop = 0, mThumbMarginBottom = 0, mThumbMarginLeft = 0, mThumbMarginRight = 0; - - private int mThumbWidth = -1, mThumbHeight = -1; - - private float density; - - private int mVelocity = -1; - - private float mRadius = -1; - - /** - * factor limit the minimum width equals almost (the height of thumb * measureFactor) - */ - private float mMeasureFactor = 0; - - /** - * inner bounds - */ - private Rect mInsetBounds; - - private Configuration() { - }; - - public static Configuration getDefault(float density) { - Configuration defaultConfiguration = new Configuration(); - defaultConfiguration.density = density; - defaultConfiguration.setThumbMarginInPixel(defaultConfiguration.getDefaultThumbMarginInPixel()); - - defaultConfiguration.mInsetBounds = new Rect(Default.DEFAULT_INNER_BOUNDS, Default.DEFAULT_INNER_BOUNDS, Default.DEFAULT_INNER_BOUNDS, Default.DEFAULT_INNER_BOUNDS); - - return defaultConfiguration; - } - - public void setBackDrawable(Drawable offDrawable, Drawable onDrawable) { - if (onDrawable == null && offDrawable == null) { - throw new IllegalArgumentException("back drawable can not be null"); - } - - if (offDrawable != null) { - mOffDrawable = offDrawable; - - if (onDrawable != null) { - mOnDrawable = onDrawable; - } else { - mOnDrawable = mOffDrawable; - } - } - } - - void setOffDrawable(Drawable offDrawable) { - if (offDrawable == null) { - throw new IllegalArgumentException("off drawable can not be null"); - } - - mOffDrawable = offDrawable; - } - - void setOnDrawable(Drawable onDrawable) { - if (onDrawable == null) { - throw new IllegalArgumentException("on drawable can not be null"); - } - - mOnDrawable = onDrawable; - } - - public Drawable getOnDrawable() { - return mOnDrawable; - } - - public Drawable getOffDrawable() { - return mOffDrawable; - } - - public void setThumbDrawable(Drawable thumbDrawable) { - if (thumbDrawable == null) { - throw new IllegalArgumentException("thumb drawable can not be null"); - } - mThumbDrawable = thumbDrawable; - } - - public Drawable getThumbDrawable() { - return mThumbDrawable; - } - - public void setThumbMargin(int top, int bottom, int left, int right) { - mThumbMarginTop = (int) (top * density); - mThumbMarginBottom = (int) (bottom * density); - mThumbMarginLeft = (int) (left * density); - mThumbMarginRight = (int) (right * density); - } - - public void setThumbMarginInPixel(int top, int bottom, int left, int right) { - mThumbMarginTop = top; - mThumbMarginBottom = bottom; - mThumbMarginLeft = left; - mThumbMarginRight = right; - } - - public void setThumbMargin(int top, int bottom, int leftAndRight) { - setThumbMargin(top, bottom, leftAndRight, leftAndRight); - } - - public void setThumbMargin(int topAndBottom, int leftAndRight) { - setThumbMargin(topAndBottom, topAndBottom, leftAndRight, leftAndRight); - } - - public void setThumbMargin(int margin) { - setThumbMargin(margin, margin, margin, margin); - } - - public void setThumbMarginInPixel(int marginInPixel) { - setThumbMarginInPixel(marginInPixel, marginInPixel, marginInPixel, marginInPixel); - } - - public int getDefaultThumbMarginInPixel() { - return (int) (Default.DEFAULT_THUMB_MARGIN * density); - } - - public int getThumbMarginTop() { - return mThumbMarginTop; - } - - public int getThumbMarginBottom() { - return mThumbMarginBottom; - } - - public int getThumbMarginLeft() { - return mThumbMarginLeft; - } - - public int getThumbMarginRight() { - return mThumbMarginRight; - } - - public float getDensity() { - return density; - } - - public void setRadius(float radius) { - this.mRadius = radius; - } - - public float getRadius() { - if (this.mRadius < 0) { - return Default.DEFAULT_RADIUS; - } - return this.mRadius; - } - - /** - * set velocity of animation - * @param velocity pixel moved per frame (in linear) - */ - public void setVelocity(int velocity) { - this.mVelocity = velocity; - } - - public int getVelocity() { - return mVelocity; - } - - public void setOnColor(int onColor) { - this.mOnColor = onColor; - } - - public int getOnColor(int onColor) { - return mOnColor; - } - - public void setOffColor(int offColor) { - this.mOffColor = offColor; - } - - public int getOffColor() { - return mOffColor; - } - - public void setThumbColor(int thumbColor) { - this.mThumbColor = thumbColor; - } - - public int getThumbColor() { - return mThumbColor; - } - - public void setThumbWidthAndHeightInPixel(int width, int height) { - if (width > 0) { - mThumbWidth = width; - } - - if (height > 0) { - mThumbHeight = height; - } - } - - public void setThumbWidthAndHeight(int width, int height) { - setThumbWidthAndHeightInPixel((int) (width * density), (int) (height * density)); - } - - public Drawable getOffDrawableWithFix() { - if (mOffDrawable != null) { - return mOffDrawable; - } else { - return getDrawableFromColor(mOffColor); - } - } - - public Drawable getOnDrawableWithFix() { - if (mOnDrawable != null) { - return mOnDrawable; - } else { - return getDrawableFromColor(mOnColor); - } - } - - public Drawable getThumbDrawableWithFix() { - if (mThumbDrawable != null) { - return mThumbDrawable; - } else { - StateListDrawable drawable = new StateListDrawable(); - Drawable normalDrawable = getDrawableFromColor(this.mThumbColor); - Drawable pressedDrawable = getDrawableFromColor(this.mThumbPressedColor); - int[] stateSet = null; - try { - Field stateField = View.class.getDeclaredField("PRESSED_ENABLED_STATE_SET"); - stateField.setAccessible(true); - stateSet = (int[]) stateField.get(null); - } catch (Exception e) { - e.printStackTrace(); - } - if (stateSet != null) { - drawable.addState(stateSet, pressedDrawable); - } - drawable.addState(new int[] {}, normalDrawable); - return drawable; - } - } - - public float getMeasureFactor() { - if (mMeasureFactor <= 0) { - mMeasureFactor = Default.DEFAULT_MEASURE_FACTOR; - } - return mMeasureFactor; - } - - public void setMeasureFactor(float measureFactor) { - if (measureFactor <= 0) { - this.mMeasureFactor = Default.DEFAULT_MEASURE_FACTOR; - } - this.mMeasureFactor = measureFactor; - } - - public Rect getInsetBounds() { - return this.mInsetBounds; - } - - public void setInsetBounds(int left, int top, int right, int bottom) { - setInsetLeft(left); - setInsetTop(top); - setInsetRight(right); - setInsetBottom(bottom); - } - - public void setInsetLeft(int left) { - if (left > 0) { - left = -left; - } - this.mInsetBounds.left = left; - } - - public void setInsetTop(int top) { - if (top > 0) { - top = -top; - } - this.mInsetBounds.top = top; - } - - public void setInsetRight(int right) { - if (right > 0) { - right = -right; - } - this.mInsetBounds.right = right; - } - - public void setInsetBottom(int bottom) { - if (bottom > 0) { - bottom = -bottom; - } - this.mInsetBounds.bottom = bottom; - } - - public int getInsetX() { - return getShrinkX() / 2; - } - - public int getInsetY() { - return getShrinkY() / 2; - } - - public int getShrinkX() { - return this.mInsetBounds.left + this.mInsetBounds.right; - } - - public int getShrinkY() { - return this.mInsetBounds.top + this.mInsetBounds.bottom; - } - - public boolean needShrink() { - return this.mInsetBounds.left + this.mInsetBounds.right + this.mInsetBounds.top + this.mInsetBounds.bottom != 0; - } - - /** - * use for get drawable from color - * - * @param color - * @return - */ - private Drawable getDrawableFromColor(int color) { - GradientDrawable tempDrawable = new GradientDrawable(); - tempDrawable.setCornerRadius(this.getRadius()); - tempDrawable.setColor(color); - return tempDrawable; - } - - int getThumbWidth() { - int width = mThumbWidth; - if (width < 0) { - if (mThumbDrawable != null) { - width = mThumbDrawable.getIntrinsicWidth(); - if (width > 0) { - return width; - } - } - if (density <= 0) { - throw new IllegalArgumentException("density must be a positive number"); - } - width = (int) (Limit.MIN_THUMB_SIZE * density); - } - return width; - } - - int getThumbHeight() { - int height = mThumbHeight; - if (height < 0) { - if (mThumbDrawable != null) { - height = mThumbDrawable.getIntrinsicHeight(); - if (height > 0) { - return height; - } - } - if (density <= 0) { - throw new IllegalArgumentException("density must be a positive number"); - } - height = (int) (Limit.MIN_THUMB_SIZE * density); - } - return height; - } -} \ No newline at end of file diff --git a/app/src/main/java/com/kyleduo/switchbutton/SwitchButton.java b/app/src/main/java/com/kyleduo/switchbutton/SwitchButton.java deleted file mode 100644 index 5db16bd3ea..0000000000 --- a/app/src/main/java/com/kyleduo/switchbutton/SwitchButton.java +++ /dev/null @@ -1,703 +0,0 @@ -package com.kyleduo.switchbutton; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.content.res.TypedArray; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Paint.Style; -import android.graphics.Rect; -import android.graphics.RectF; -import android.graphics.Region; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.StateListDrawable; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewConfiguration; -import android.view.ViewGroup; -import android.view.ViewParent; -import android.widget.CompoundButton; - -import com.gh.gamecenter.R; - -/** - * SwitchButton widget which is easy to use - * - * @version 1.2 - * @author kyleduo - * @since 2014-09-24 - */ - -public class SwitchButton extends CompoundButton { - private static boolean SHOW_RECT = false; - - private boolean mIsChecked = false; - - private Configuration mConf; - - /** - * zone for thumb to move inside - */ - private Rect mSafeZone; - /** - * zone for background - */ - private Rect mBackZone; - private Rect mThumbZone; - private RectF mSaveLayerZone; - - private AnimationController mAnimationController; - private SBAnimationListener mOnAnimateListener = new SBAnimationListener(); - private boolean isAnimating = false; - - private float mStartX, mStartY, mLastX; - private float mCenterPos; - - private int mTouchSlop; - private int mClickTimeout; - - private Paint mRectPaint; - - private Rect mBounds = null; - - private OnCheckedChangeListener mOnCheckedChangeListener; - - @SuppressLint("NewApi") - public SwitchButton(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - initView(); - - TypedArray ta = context.obtainStyledAttributes(attrs, - R.styleable.SwitchButton); - - mConf.setThumbMarginInPixel(ta.getDimensionPixelSize( - R.styleable.SwitchButton_thumb_margin, - mConf.getDefaultThumbMarginInPixel())); - mConf.setThumbMarginInPixel(ta.getDimensionPixelSize( - R.styleable.SwitchButton_thumb_marginTop, - mConf.getThumbMarginTop()), ta.getDimensionPixelSize( - R.styleable.SwitchButton_thumb_marginBottom, - mConf.getThumbMarginBottom()), ta.getDimensionPixelSize( - R.styleable.SwitchButton_thumb_marginLeft, - mConf.getThumbMarginLeft()), ta.getDimensionPixelSize( - R.styleable.SwitchButton_thumb_marginRight, - mConf.getThumbMarginRight())); - mConf.setRadius(ta.getInt(R.styleable.SwitchButton_radius, - Configuration.Default.DEFAULT_RADIUS)); - - mConf.setThumbWidthAndHeightInPixel(ta.getDimensionPixelSize( - R.styleable.SwitchButton_thumb_width, -1), ta - .getDimensionPixelSize(R.styleable.SwitchButton_thumb_height, - -1)); - - mConf.setMeasureFactor(ta.getFloat( - R.styleable.SwitchButton_measureFactor, -1)); - - mConf.setInsetBounds( - ta.getDimensionPixelSize(R.styleable.SwitchButton_insetLeft, 0), - ta.getDimensionPixelSize(R.styleable.SwitchButton_insetTop, 0), - ta.getDimensionPixelSize(R.styleable.SwitchButton_insetRight, 0), - ta.getDimensionPixelSize(R.styleable.SwitchButton_insetBottom, 0)); - - int velocity = ta.getInteger(R.styleable.SwitchButton_animationVelocity, -1); - mAnimationController.setVelocity(velocity); - - fetchDrawableFromAttr(ta); - ta.recycle(); - - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { - this.setLayerType(View.LAYER_TYPE_SOFTWARE, null); - } - } - - public SwitchButton(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public SwitchButton(Context context) { - this(context, null); - } - - private void initView() { - mConf = Configuration.getDefault(getContext().getResources() - .getDisplayMetrics().density); - mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); - mClickTimeout = ViewConfiguration.getPressedStateDuration() - + ViewConfiguration.getTapTimeout(); - mAnimationController = AnimationController.getDefault().init( - mOnAnimateListener); - mBounds = new Rect(); - if (SHOW_RECT) { - mRectPaint = new Paint(); - mRectPaint.setStyle(Style.STROKE); - } - } - - /** - * fetch drawable resources from attrs, drop them to conf, AFTER the size - * has been confirmed - * - * @param ta - */ - private void fetchDrawableFromAttr(TypedArray ta) { - if (mConf == null) { - return; - } -// mConf.setOffDrawable(fetchDrawable(ta, -// R.styleable.SwitchButton_offDrawable, -// R.styleable.SwitchButton_offColor, -// Configuration.Default.DEFAULT_OFF_COLOR)); -// mConf.setOnDrawable(fetchDrawable(ta, -// R.styleable.SwitchButton_onDrawable, -// R.styleable.SwitchButton_onColor, -// Configuration.Default.DEFAULT_ON_COLOR)); - mConf.setOffDrawable(fetchDrawable(Configuration.Default.DEFAULT_OFF_COLOR)); - mConf.setOnDrawable(fetchDrawable(Configuration.Default.DEFAULT_ON_COLOR)); - mConf.setThumbDrawable(fetchThumbDrawable(ta)); - } - - private Drawable fetchDrawable(int defaultColor) { - GradientDrawable tempDrawable = new GradientDrawable(); - tempDrawable.setCornerRadius(0); - tempDrawable.setColor(defaultColor); - return tempDrawable; - } - - private Drawable fetchDrawable(TypedArray ta, int attrId, int alterColorId, - int defaultColor) { - Drawable tempDrawable = ta.getDrawable(attrId); - if (tempDrawable == null) { - int tempColor = ta.getColor(alterColorId, defaultColor); - tempDrawable = new GradientDrawable(); - ((GradientDrawable) tempDrawable).setCornerRadius(0); - - ((GradientDrawable) tempDrawable).setColor(tempColor); - } - return tempDrawable; - } - - private Drawable fetchThumbDrawable(TypedArray ta) { - - Drawable tempDrawable = ta - .getDrawable(R.styleable.SwitchButton_thumbDrawable); - if (tempDrawable != null) { - return tempDrawable; - } - - int normalColor = ta.getColor(R.styleable.SwitchButton_thumbColor, - Configuration.Default.DEFAULT_THUMB_COLOR); - int pressedColor = ta.getColor( - R.styleable.SwitchButton_thumbPressedColor, - Configuration.Default.DEFAULT_THUMB_PRESSED_COLOR); - - StateListDrawable drawable = new StateListDrawable(); - GradientDrawable normalDrawable = new GradientDrawable(); - normalDrawable.setCornerRadius(this.mConf.getRadius()); - normalDrawable.setColor(normalColor); - GradientDrawable pressedDrawable = new GradientDrawable(); - pressedDrawable.setCornerRadius(this.mConf.getRadius()); - pressedDrawable.setColor(pressedColor); - drawable.addState(View.PRESSED_ENABLED_STATE_SET, pressedDrawable); - drawable.addState(new int[] {}, normalDrawable); - - return drawable; - } - - public void setConfiguration(Configuration conf) { - if (mConf == null) { - mConf = Configuration.getDefault(conf.getDensity()); - } - mConf.setOffDrawable(conf.getOffDrawableWithFix()); - mConf.setOnDrawable(conf.getOnDrawableWithFix()); - mConf.setThumbDrawable(conf.getThumbDrawableWithFix()); - mConf.setThumbMarginInPixel(conf.getThumbMarginTop(), - conf.getThumbMarginBottom(), conf.getThumbMarginLeft(), - conf.getThumbMarginRight()); - mConf.setThumbWidthAndHeightInPixel(conf.getThumbWidth(), - conf.getThumbHeight()); - mConf.setVelocity(conf.getVelocity()); - mConf.setMeasureFactor(conf.getMeasureFactor()); - mAnimationController.setVelocity(mConf.getVelocity()); - this.requestLayout(); - setup(); - setChecked(mIsChecked); - } - - /** - * return a REFERENCE of configuration, it is suggested that not to change - * that - * - * @return - */ - public Configuration getConfiguration() { - return mConf; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(measureWidth(widthMeasureSpec), - measureHeight(heightMeasureSpec)); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - setup(); - } - - private void setup() { - setupBackZone(); - setupSafeZone(); - setupThumbZone(); - - setupDrawableBounds(); - if (this.getMeasuredWidth() > 0 && this.getMeasuredHeight() > 0) { - mSaveLayerZone = new RectF(0, 0, this.getMeasuredWidth(), - this.getMeasuredHeight()); - } - - ViewGroup parent = (ViewGroup) this.getParent(); - if (parent != null) { - parent.setClipChildren(false); - } - } - - /** - * setup zone for thumb to move - */ - private void setupSafeZone() { - int w = getMeasuredWidth(); - int h = getMeasuredHeight(); - if (w > 0 && h > 0) { - if (mSafeZone == null) { - mSafeZone = new Rect(); - } - int left, right, top, bottom; - left = getPaddingLeft() - + (mConf.getThumbMarginLeft() > 0 ? mConf - .getThumbMarginLeft() : 0); - right = w - - getPaddingRight() - - (mConf.getThumbMarginRight() > 0 ? mConf - .getThumbMarginRight() : 0) + (-mConf.getShrinkX()); - top = getPaddingTop() - + (mConf.getThumbMarginTop() > 0 ? mConf - .getThumbMarginTop() : 0); - bottom = h - - getPaddingBottom() - - (mConf.getThumbMarginBottom() > 0 ? mConf - .getThumbMarginBottom() : 0) - + (-mConf.getShrinkY()); - mSafeZone.set(left, top, right, bottom); - - mCenterPos = mSafeZone.left - + (mSafeZone.right - mSafeZone.left - mConf.getThumbWidth()) - / 2; - } else { - mSafeZone = null; - } - } - - private void setupBackZone() { - int w = getMeasuredWidth(); - int h = getMeasuredHeight(); - if (w > 0 && h > 0) { - if (mBackZone == null) { - mBackZone = new Rect(); - } - int left, right, top, bottom; - left = getPaddingLeft() - + (mConf.getThumbMarginLeft() > 0 ? 0 : -mConf - .getThumbMarginLeft()); - right = w - - getPaddingRight() - - (mConf.getThumbMarginRight() > 0 ? 0 : -mConf - .getThumbMarginRight()) + (-mConf.getShrinkX()); - top = getPaddingTop() - + (mConf.getThumbMarginTop() > 0 ? 0 : -mConf - .getThumbMarginTop()); - bottom = h - - getPaddingBottom() - - (mConf.getThumbMarginBottom() > 0 ? 0 : -mConf - .getThumbMarginBottom()) + (-mConf.getShrinkY()); - int dec = (int) (1.5 * getContext().getResources().getDisplayMetrics().density + 0.5f); - mBackZone.set(left - dec, top - dec, right + dec, bottom + dec); - } else { - mBackZone = null; - } - } - - private void setupThumbZone() { - int w = getMeasuredWidth(); - int h = getMeasuredHeight(); - if (w > 0 && h > 0) { - if (mThumbZone == null) { - mThumbZone = new Rect(); - } - int left, right, top, bottom; - left = mIsChecked ? (mSafeZone.right - mConf.getThumbWidth()) - : mSafeZone.left; - right = left + mConf.getThumbWidth(); - top = mSafeZone.top; - bottom = top + mConf.getThumbHeight(); - mThumbZone.set(left, top, right, bottom); - } else { - mThumbZone = null; - } - } - - private void setupDrawableBounds() { - if (mBackZone != null) { - mConf.getOnDrawable().setBounds(mBackZone); - mConf.getOffDrawable().setBounds(mBackZone); - } - if (mThumbZone != null) { - mConf.getThumbDrawable().setBounds(mThumbZone); - } - } - - private int measureWidth(int measureSpec) { - int measuredWidth = 0; - - int specMode = MeasureSpec.getMode(measureSpec); - int specSize = MeasureSpec.getSize(measureSpec); - - int minWidth = (int) (mConf.getThumbWidth() * mConf.getMeasureFactor() - + getPaddingLeft() + getPaddingRight()); - int innerMarginWidth = mConf.getThumbMarginLeft() - + mConf.getThumbMarginRight(); - if (innerMarginWidth > 0) { - minWidth += innerMarginWidth; - } - - if (specMode == MeasureSpec.EXACTLY) { - measuredWidth = Math.max(specSize, minWidth); - } else { - measuredWidth = minWidth; - if (specMode == MeasureSpec.AT_MOST) { - measuredWidth = Math.min(specSize, minWidth); - } - } - - // bounds are negative numbers - measuredWidth += (mConf.getInsetBounds().left + mConf.getInsetBounds().right); - - return measuredWidth; - } - - private int measureHeight(int measureSpec) { - int measuredHeight = 0; - - int specMode = MeasureSpec.getMode(measureSpec); - int specSize = MeasureSpec.getSize(measureSpec); - - int minHeight = mConf.getThumbHeight() + getPaddingTop() - + getPaddingBottom(); - int innerMarginHeight = mConf.getThumbMarginTop() - + mConf.getThumbMarginBottom(); - - if (innerMarginHeight > 0) { - minHeight += innerMarginHeight; - } - - if (specMode == MeasureSpec.EXACTLY) { - measuredHeight = Math.max(specSize, minHeight); - } else { - measuredHeight = minHeight; - if (specMode == MeasureSpec.AT_MOST) { - measuredHeight = Math.min(specSize, minHeight); - } - } - - measuredHeight += (mConf.getInsetBounds().top + mConf.getInsetBounds().bottom); - - return measuredHeight; - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - canvas.getClipBounds(mBounds); - if (mBounds != null && mConf.needShrink()) { - mBounds.inset(mConf.getInsetX(), mConf.getInsetY()); - canvas.clipRect(mBounds, Region.Op.REPLACE); - canvas.translate(mConf.getInsetBounds().left, mConf.getInsetBounds().top); - } - - boolean useGeneralDisableEffect = !isEnabled() && this.notStatableDrawable(); - if (useGeneralDisableEffect) { - canvas.saveLayerAlpha(mSaveLayerZone, 255 / 2, - Canvas.MATRIX_SAVE_FLAG | Canvas.CLIP_SAVE_FLAG - | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG - | Canvas.FULL_COLOR_LAYER_SAVE_FLAG - | Canvas.CLIP_TO_LAYER_SAVE_FLAG); - } - -// mConf.getOffDrawable().setBounds(75, 75, 177, 105); - mConf.getOffDrawable().draw(canvas); -// mConf.getOnDrawable().setBounds(75, 75, 177, 105); - mConf.getOnDrawable().setAlpha(calcAlpha()); - mConf.getOnDrawable().draw(canvas); - mConf.getThumbDrawable().draw(canvas); - - if (useGeneralDisableEffect) { - canvas.restore(); - } - - if (SHOW_RECT) { - mRectPaint.setColor(Color.parseColor("#AA0000")); - canvas.drawRect(mBackZone, mRectPaint); - mRectPaint.setColor(Color.parseColor("#00FF00")); - canvas.drawRect(mSafeZone, mRectPaint); - mRectPaint.setColor(Color.parseColor("#0000FF")); - canvas.drawRect(mThumbZone, mRectPaint); - } - } - - private boolean notStatableDrawable() { - boolean thumbStatable = (mConf.getThumbDrawable() instanceof StateListDrawable); - boolean onStatable = (mConf.getOnDrawable() instanceof StateListDrawable); - boolean offStatable = (mConf.getOffDrawable() instanceof StateListDrawable); - return !thumbStatable || !onStatable || !offStatable; - } - - /** - * calculate the alpha value for on layer - * - * @return 0 ~ 255 - */ - private int calcAlpha() { - int alpha = 255; - if (mSafeZone == null || mSafeZone.right == mSafeZone.left) { - - } else { - int backWidth = mSafeZone.right - mConf.getThumbWidth() - - mSafeZone.left; - if (backWidth > 0) { - alpha = (mThumbZone.left - mSafeZone.left) * 255 / backWidth; - } - } - - return alpha; - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - - if (isAnimating || !isEnabled()) { - return false; - } - int action = event.getAction(); - - float deltaX = event.getX() - mStartX; - float deltaY = event.getY() - mStartY; - - // status the view going to change to when finger released - boolean nextStatus = mIsChecked; - - switch (action) { - case MotionEvent.ACTION_DOWN: - catchView(); - mStartX = event.getX(); - mStartY = event.getY(); - mLastX = mStartX; - setPressed(true); - break; - - case MotionEvent.ACTION_MOVE: - float x = event.getX(); - moveThumb((int) (x - mLastX)); - mLastX = x; - break; - - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_UP: - setPressed(false); - - nextStatus = getStatusBasedOnPos(); - - float time = event.getEventTime() - event.getDownTime(); - - if (deltaX < mTouchSlop && deltaY < mTouchSlop - && time < mClickTimeout) { - performClick(); - } else { - slideToChecked(nextStatus); - } - - break; - - default: - break; - } - invalidate(); - return true; - } - - /** - * return the status based on position of thumb - * - * @return - */ - private boolean getStatusBasedOnPos() { - return mThumbZone.left > mCenterPos; - } - - @Override - public void invalidate() { - if (mBounds != null && mConf.needShrink()) { - invalidate(mBounds); - } else { - super.invalidate(); - } - } - - @Override - public boolean performClick() { - return super.performClick(); - } - - private void catchView() { - ViewParent parent = getParent(); - if (parent != null) { - parent.requestDisallowInterceptTouchEvent(true); - } - } - - @Override - public void setChecked(final boolean checked) { - setChecked(checked, true); - } - - public void setChecked(final boolean checked, boolean trigger) { - if (mThumbZone != null) { - moveThumb(checked ? getMeasuredWidth() : -getMeasuredWidth()); - } - setCheckedInClass(checked, trigger); - } - - @Override - public boolean isChecked() { - return mIsChecked; - } - - @Override - public void toggle() { - toggle(true); - } - - public void toggle(boolean animated) { - if (animated) { - slideToChecked(!mIsChecked); - } else { - setChecked(!mIsChecked); - } - } - - @Override - protected void drawableStateChanged() { - super.drawableStateChanged(); - if (mConf == null) { - return; - } - setDrawableState(mConf.getThumbDrawable()); - setDrawableState(mConf.getOnDrawable()); - setDrawableState(mConf.getOffDrawable()); - } - - private void setDrawableState(Drawable drawable) { - if (drawable != null) { - int[] myDrawableState = getDrawableState(); - drawable.setState(myDrawableState); - invalidate(); - } - } - - public void setOnCheckedChangeListener( - OnCheckedChangeListener onCheckedChangeListener) { - if (onCheckedChangeListener == null) { - throw new IllegalArgumentException( - "onCheckedChangeListener can not be null"); - } - mOnCheckedChangeListener = onCheckedChangeListener; - } - - private void setCheckedInClass(boolean checked) { - setCheckedInClass(checked, true); - } - - private void setCheckedInClass(boolean checked, boolean trigger) { - if (mIsChecked == checked) { - return; - } - mIsChecked = checked; - - refreshDrawableState(); - - if (mOnCheckedChangeListener != null && trigger) { - mOnCheckedChangeListener.onCheckedChanged(this, mIsChecked); - } - } - - public void slideToChecked(boolean checked) { - if (isAnimating) { - return; - } - int from = mThumbZone.left; - int to = checked ? mSafeZone.right - mConf.getThumbWidth() - : mSafeZone.left; - mAnimationController.startAnimation(from, to); - } - - private void moveThumb(int delta) { - - int newLeft = mThumbZone.left + delta; - int newRight = mThumbZone.right + delta; - if (newLeft < mSafeZone.left) { - newLeft = mSafeZone.left; - newRight = newLeft + mConf.getThumbWidth(); - } - if (newRight > mSafeZone.right) { - newRight = mSafeZone.right; - newLeft = newRight - mConf.getThumbWidth(); - } - - moveThumbTo(newLeft, newRight); - } - - private void moveThumbTo(int newLeft, int newRight) { - mThumbZone.set(newLeft, mThumbZone.top, newRight, mThumbZone.bottom); - mConf.getThumbDrawable().setBounds(mThumbZone); - } - - class SBAnimationListener implements AnimationController.OnAnimateListener { - - @Override - public void onAnimationStart() { - isAnimating = true; - } - - @Override - public boolean continueAnimating() { - return mThumbZone.right < mSafeZone.right - && mThumbZone.left > mSafeZone.left; - } - - @Override - public void onFrameUpdate(int frame) { - moveThumb(frame); - postInvalidate(); - } - - @Override - public void onAnimateComplete() { - setCheckedInClass(getStatusBasedOnPos()); - isAnimating = false; - } - - } -} diff --git a/app/src/main/res/layout/activity_setting.xml b/app/src/main/res/layout/activity_setting.xml index 9186d5e168..3732ad22ce 100644 --- a/app/src/main/res/layout/activity_setting.xml +++ b/app/src/main/res/layout/activity_setting.xml @@ -108,7 +108,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/values/ssdk_instapaper_strings.xml b/app/src/main/res/values/ssdk_instapaper_strings.xml deleted file mode 100644 index ca6c4ae59c..0000000000 --- a/app/src/main/res/values/ssdk_instapaper_strings.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - -%s - - - - - -
-%s -
- - - -
-

-
- - -]]>
-
\ No newline at end of file diff --git a/app/src/main/res/values/ssdk_oks_color_drawables.xml b/app/src/main/res/values/ssdk_oks_color_drawables.xml deleted file mode 100644 index ae1181f37c..0000000000 --- a/app/src/main/res/values/ssdk_oks_color_drawables.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - #ffffffff - #ffeeeeee - diff --git a/app/src/main/res/values/ssdk_oks_strings.xml b/app/src/main/res/values/ssdk_oks_strings.xml deleted file mode 100644 index 548bf276d8..0000000000 --- a/app/src/main/res/values/ssdk_oks_strings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 分享 - 分享操作正在后台进行… - 分享失败 - 分享成功 - 分享已取消 - 取消 - 图文分享 - 确定 - 联系人 - 下拉刷新 - 松开刷新 - 刷新中… - diff --git a/app/src/main/res/values/ssdk_strings.xml b/app/src/main/res/values/ssdk_strings.xml deleted file mode 100644 index 4177cd24c1..0000000000 --- a/app/src/main/res/values/ssdk_strings.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - 应用授权 - http://www.mob.com - 分享图片 - 目前您的微信版本过低或未安装微信,需要安装微信才能使用 - Google+ 版本过低或者没有安装,需要升级或安装Google+才能使用! - QQ 版本过低或者没有安装,需要升级或安装QQ才能使用! - Pinterest版本过低或者没有安装,需要升级或安装Pinterest才能使用! - Instagram版本过低或者没有安装,需要升级或安装Instagram才能使用! - 目前您的易信版本过低或未安装,需要安装易信才能使用 - 目前您的Line版本过低或未安装,需要安装Line才能使用 - 目前您的KakaoTalk版本过低或未安装,需要安装KakaoTalk才能使用 - 目前您的KakaoStory版本过低或未安装,需要安装KakaoStory才能使用 - 目前您的WhatsApp版本过低或未安装,需要安装WhatsApp才能使用 - 目前您的百度贴吧版本过低或未安装,需要安装百度贴吧才能使用 - 目前您的来往版本过低或未安装,需要安装来往才能使用 - 目前您的支付宝版本过低或未安装,需要安装支付宝才能使用 - 目前您的FacebookMessenger版本过低或未安装,需要安装才能使用 - - 新浪微博 - 腾讯微博 - QQ空间 - 微信好友 - 微信朋友圈 - 微信收藏 - Facebook - Twitter - 人人网 - 开心网 - 邮件 - 信息 - 搜狐微博 - 搜狐随身看 - 网易微博 - 豆瓣 - 有道云笔记 - 印象笔记 - 领英 - Google+ - FourSquare - QQ - Pinterest - Flickr - Tumblr - Dropbox - VK - Instagram - 易信 - 易信朋友圈 - 明道 - KakaoTalk - KakaoStory - Line - 蓝牙 - WhatsApp - Pocket - Instapaper - 邮箱 - 密码 - 登录 - 登录中… - Email或密码不正确 - Facebook Messenger - 百度贴吧 - 来往 - 来往动态 - 支付宝好友 - - 分享到百度贴吧 - 分享到QQ空间 - 分享到QQ - 网页分享 - 分享到明道 - 来自%s的分享 - 请改用“登录”按钮 - \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0fc1ea5e5d..81cff83ca9 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -69,19 +69,6 @@ - - diff --git a/libraries/MiPush/libs/MiPush_SDK_Client_3_1_2.jar b/libraries/MiPush/libs/MiPush_SDK_Client_3_1_2.jar deleted file mode 100644 index 3ed84821e1..0000000000 Binary files a/libraries/MiPush/libs/MiPush_SDK_Client_3_1_2.jar and /dev/null differ diff --git a/libraries/MiPush/libs/MiPush_SDK_Client_3_2_2.jar b/libraries/MiPush/libs/MiPush_SDK_Client_3_2_2.jar new file mode 100644 index 0000000000..bd8562ea32 Binary files /dev/null and b/libraries/MiPush/libs/MiPush_SDK_Client_3_2_2.jar differ diff --git a/libraries/MiPush/proguard-library.txt b/libraries/MiPush/proguard-library.txt index 5b89420dba..18231a64b0 100644 --- a/libraries/MiPush/proguard-library.txt +++ b/libraries/MiPush/proguard-library.txt @@ -17,4 +17,7 @@ # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; -#} \ No newline at end of file +#} + +-keep class com.gh.base.GHPushMessageReceiver {*;} +-dontwarn com.xiaomi.push.** \ No newline at end of file diff --git a/libraries/MiPush/src/main/AndroidManifest.xml b/libraries/MiPush/src/main/AndroidManifest.xml index 32099f9d76..7f29e2f5a1 100644 --- a/libraries/MiPush/src/main/AndroidManifest.xml +++ b/libraries/MiPush/src/main/AndroidManifest.xml @@ -1,6 +1,75 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/QQShare/src/main/AndroidManifest.xml b/libraries/QQShare/src/main/AndroidManifest.xml index f40d865f9d..38492700d1 100644 --- a/libraries/QQShare/src/main/AndroidManifest.xml +++ b/libraries/QQShare/src/main/AndroidManifest.xml @@ -1,6 +1,28 @@ - + + + + + + + + + + + + + + + + + diff --git a/libraries/TalkingData/libs/TalkingDataAnalytics_V1.2.79.jar b/libraries/TalkingData/libs/TalkingDataAnalytics_V1.2.79.jar deleted file mode 100644 index a0adfd9247..0000000000 Binary files a/libraries/TalkingData/libs/TalkingDataAnalytics_V1.2.79.jar and /dev/null differ diff --git a/libraries/TalkingData/libs/TalkingData_AppAnalytics_Android_SDK_V2.3.62.jar b/libraries/TalkingData/libs/TalkingData_AppAnalytics_Android_SDK_V2.3.62.jar new file mode 100644 index 0000000000..db5a80266c Binary files /dev/null and b/libraries/TalkingData/libs/TalkingData_AppAnalytics_Android_SDK_V2.3.62.jar differ diff --git a/libraries/TalkingData/proguard-library.txt b/libraries/TalkingData/proguard-library.txt index 5b89420dba..fd0fd9ca0f 100644 --- a/libraries/TalkingData/proguard-library.txt +++ b/libraries/TalkingData/proguard-library.txt @@ -17,4 +17,15 @@ # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; -#} \ No newline at end of file +#} + +-dontwarn com.tendcloud.tenddata.** +-keep class com.tendcloud.** {*;} +-keep public class com.tendcloud.tenddata.** { public protected *;} +-keepclassmembers class com.tendcloud.tenddata.**{ +public void *(***); +} +-keep class com.talkingdata.sdk.TalkingDataSDK {public *;} +-keep class com.apptalkingdata.** {*;} +-keep class dice.** {*; } +-dontwarn dice.** \ No newline at end of file diff --git a/libraries/TalkingData/src/main/AndroidManifest.xml b/libraries/TalkingData/src/main/AndroidManifest.xml index 1a509ace72..dece9e7d7a 100644 --- a/libraries/TalkingData/src/main/AndroidManifest.xml +++ b/libraries/TalkingData/src/main/AndroidManifest.xml @@ -3,4 +3,32 @@ xmlns:android = "http://schemas.android.com/apk/res/android" > + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/UmengPush/proguard-library.txt b/libraries/UmengPush/proguard-library.txt index 5b89420dba..2f62e149ce 100644 --- a/libraries/UmengPush/proguard-library.txt +++ b/libraries/UmengPush/proguard-library.txt @@ -17,4 +17,38 @@ # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; -#} \ No newline at end of file +#} + +-dontwarn com.taobao.** +-dontwarn anet.channel.** +-dontwarn anetwork.channel.** +-dontwarn org.android.** +-dontwarn org.apache.thrift.** +-dontwarn com.xiaomi.** +-dontwarn com.huawei.** + +-keepattributes *Annotation* + +-keep class com.taobao.** {*;} +-keep class org.android.** {*;} +-keep class anet.channel.** {*;} +-keep class com.umeng.** {*;} +-keep class com.xiaomi.** {*;} +-keep class com.huawei.** {*;} +-keep class org.apache.thrift.** {*;} + +-keep class com.alibaba.sdk.android.**{*;} +-keep class com.ut.**{*;} +-keep class com.ta.**{*;} + +-keep public class **.R$*{ + public static final int *; +} + +#(可选)避免Log打印输出 +#-assumenosideeffects class android.util.Log { +# public static *** v(...); +# public static *** d(...); +# public static *** i(...); +# public static *** w(...); +# } \ No newline at end of file diff --git a/libraries/UmengPush/src/main/AndroidManifest.xml b/libraries/UmengPush/src/main/AndroidManifest.xml index 93ff181d68..3afdcc10a1 100644 --- a/libraries/UmengPush/src/main/AndroidManifest.xml +++ b/libraries/UmengPush/src/main/AndroidManifest.xml @@ -22,6 +22,24 @@ + + + + + + + + + + + + + + - + @@ -138,7 +156,7 @@ diff --git a/libraries/WechatShare/build.gradle b/libraries/WechatShare/build.gradle index 42c5bc2c65..89d074a4f1 100644 --- a/libraries/WechatShare/build.gradle +++ b/libraries/WechatShare/build.gradle @@ -2,4 +2,10 @@ apply plugin: 'com.android.library' dependencies { compile fileTree(dir: 'libs', exclude: 'android-support-*.jar', include: '*.jar') +} + +android { + defaultConfig { + consumerProguardFiles 'proguard-library.txt' + } } \ No newline at end of file diff --git a/libraries/WechatShare/proguard-library.txt b/libraries/WechatShare/proguard-library.txt new file mode 100644 index 0000000000..751646a689 --- /dev/null +++ b/libraries/WechatShare/proguard-library.txt @@ -0,0 +1,30 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +-keep class com.tencent.mm.opensdk.** { + *; +} +-keep class com.tencent.wxop.** { + *; +} +-keep class com.tencent.mm.sdk.** { + *; +} \ No newline at end of file diff --git a/libraries/WechatShare/src/main/AndroidManifest.xml b/libraries/WechatShare/src/main/AndroidManifest.xml index 47b603e280..d6d0888b48 100644 --- a/libraries/WechatShare/src/main/AndroidManifest.xml +++ b/libraries/WechatShare/src/main/AndroidManifest.xml @@ -2,4 +2,26 @@ + + + + + + + + + + + + + + + + diff --git a/libraries/WeiboShare/src/main/AndroidManifest.xml b/libraries/WeiboShare/src/main/AndroidManifest.xml index 57ade52b09..929e84f565 100644 --- a/libraries/WeiboShare/src/main/AndroidManifest.xml +++ b/libraries/WeiboShare/src/main/AndroidManifest.xml @@ -1,6 +1,40 @@ + xmlns:android = "http://schemas.android.com/apk/res/android" > + + + + + + + + + + + + + + + + + + + + + + + + +