diff --git a/.idea/misc.xml b/.idea/misc.xml index 5716de1c..8ce21776 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,8 +1,5 @@ - - - @@ -30,17 +27,7 @@ - - - - - - - - - - - + diff --git a/.idea/modules.xml b/.idea/modules.xml index 0732e42d..ba3392f2 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,8 @@ - - + + \ No newline at end of file diff --git a/.idea/modules/app/app.iml b/.idea/modules/app/app.iml deleted file mode 100644 index 50059d59..00000000 --- a/.idea/modules/app/app.iml +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460d..00000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules/WeChatLuckyMoney.iml b/WeChatLuckyMoney.iml similarity index 57% rename from .idea/modules/WeChatLuckyMoney.iml rename to WeChatLuckyMoney.iml index c8610159..cfb23148 100644 --- a/.idea/modules/WeChatLuckyMoney.iml +++ b/WeChatLuckyMoney.iml @@ -1,17 +1,17 @@ - + - - - + + diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 00000000..c9b31198 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index d1e8db9c..31187eb3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,5 +39,5 @@ dependencies { compile 'com.android.support:appcompat-v7:22.1.1' //compile 'com.tencent.bugly:crashreport:latest.release' //其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.2.8 compile 'com.tencent.bugly:crashreport_upgrade:latest.release'//其中latest.release指代最新版本号,也可以指定明确的版本号,例如1.0.1 -} - + compile 'com.google.android.gms:play-services-ads:8.4.0' +} \ No newline at end of file diff --git a/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java b/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java index 137e4e54..29170731 100644 --- a/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java +++ b/app/src/main/java/xyz/monkeytong/hongbao/activities/MainActivity.java @@ -5,10 +5,8 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.media.Image; import android.os.Build; import android.os.Bundle; -import android.os.Parcelable; import android.preference.PreferenceManager; import android.provider.Settings; import android.view.View; @@ -19,8 +17,9 @@ import java.util.List; +import com.google.android.gms.ads.AdRequest; +import com.google.android.gms.ads.AdView; import xyz.monkeytong.hongbao.R; -import xyz.monkeytong.hongbao.fragments.GeneralSettingsFragment; import xyz.monkeytong.hongbao.utils.ConnectivityUtil; import xyz.monkeytong.hongbao.utils.UpdateTask; @@ -35,6 +34,8 @@ public class MainActivity extends Activity implements AccessibilityManager.Acces //AccessibilityService 管理 private AccessibilityManager accessibilityManager; + private AdView adView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -43,6 +44,8 @@ protected void onCreate(Bundle savedInstanceState) { pluginStatusText = (TextView) findViewById(R.id.layout_control_accessibility_text); pluginStatusIcon = (ImageView) findViewById(R.id.layout_control_accessibility_icon); + loadAd(); + handleMaterialStatusBar(); explicitlyLoadPreferences(); @@ -75,9 +78,26 @@ private void handleMaterialStatusBar() { } + private void loadAd() { + adView = (AdView) findViewById(R.id.adViewMain); + AdRequest adRequest = new AdRequest.Builder().build(); + adView.loadAd(adRequest); + } + + @Override + protected void onPause() { + if (adView != null) { + adView.pause(); + } + super.onPause(); + } + @Override protected void onResume() { super.onResume(); + if (adView != null) { + adView.resume(); + } // Check for update when WIFI is connected or on first time. if (ConnectivityUtil.isWifi(this) || UpdateTask.count == 0) @@ -86,6 +106,9 @@ protected void onResume() { @Override protected void onDestroy() { + if (adView != null) { + adView.destroy(); + } //移除监听服务 accessibilityManager.removeAccessibilityStateChangeListener(this); super.onDestroy(); @@ -112,8 +135,10 @@ public void openGitHub(View view) { public void openUber(View view) { Intent webViewIntent = new Intent(this, WebViewActivity.class); - webViewIntent.putExtra("title", "Uber 优惠乘车机会(优惠码rgk2wue)"); - webViewIntent.putExtra("url", "https://get.uber.com.cn/invite/rgk2wue"); + webViewIntent.putExtra("title", "Uber 优惠乘车"); + String[] couponList = new String[]{"https://dc.tt/oTLtXH2BHsD", "https://dc.tt/ozFJHDnfLky"}; + int index = (int) (Math.random() * 2); + webViewIntent.putExtra("url", couponList[index]); startActivity(webViewIntent); } diff --git a/app/src/main/java/xyz/monkeytong/hongbao/activities/WebViewActivity.java b/app/src/main/java/xyz/monkeytong/hongbao/activities/WebViewActivity.java index a2e79194..ba163dfc 100644 --- a/app/src/main/java/xyz/monkeytong/hongbao/activities/WebViewActivity.java +++ b/app/src/main/java/xyz/monkeytong/hongbao/activities/WebViewActivity.java @@ -24,6 +24,8 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; +import com.google.android.gms.ads.AdRequest; +import com.google.android.gms.ads.AdView; import xyz.monkeytong.hongbao.R; import xyz.monkeytong.hongbao.utils.DownloadUtil; import xyz.monkeytong.hongbao.utils.UpdateTask; @@ -36,6 +38,8 @@ public class WebViewActivity extends Activity { private WebView webView; private String webViewUrl, webViewTitle; + private AdView adView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -47,7 +51,7 @@ protected void onCreate(Bundle savedInstanceState) { webViewTitle = bundle.getString("title"); webViewUrl = bundle.getString("url"); - TextView webViewBar = (TextView) findViewById(R.id.webview_bar); + final TextView webViewBar = (TextView) findViewById(R.id.webview_bar); webViewBar.setText(webViewTitle); webView = (WebView) findViewById(R.id.webView); @@ -58,10 +62,14 @@ protected void onCreate(Bundle savedInstanceState) { webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { - if (url.indexOf("apk") > 0) { - Toast.makeText(getApplicationContext(), "正在准备下载", Toast.LENGTH_SHORT).show(); + if (url.contains("apk")) { + Toast.makeText(getApplicationContext(), "正在后台下载", Toast.LENGTH_SHORT).show(); (new DownloadUtil()).enqueue(url, getApplicationContext()); return true; + } else if (!url.contains("http")) { + Toast.makeText(getApplicationContext(), "正在前往下载页面", Toast.LENGTH_LONG).show(); + webViewBar.setText("点击\"普通下载\"获取 Uber"); + return false; } else { view.loadUrl(url); return false; @@ -75,6 +83,38 @@ public void onPageFinished(WebView view, String url) { }); webView.loadUrl(webViewUrl); } + + loadAd(); + } + + @Override + protected void onPause() { + if (adView != null) { + adView.pause(); + } + super.onPause(); + } + + @Override + protected void onResume() { + super.onResume(); + if (adView != null) { + adView.resume(); + } + } + + @Override + protected void onDestroy() { + if (adView != null) { + adView.destroy(); + } + super.onDestroy(); + } + + private void loadAd() { + adView = (AdView) findViewById(R.id.adViewWebView); + AdRequest adRequest = new AdRequest.Builder().build(); + adView.loadAd(adRequest); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @@ -92,11 +132,6 @@ private void loadUI() { window.setStatusBarColor(0xffE46C62); } - @Override - protected void onResume() { - super.onResume(); - } - public void performBack(View view) { super.onBackPressed(); } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 055e3f34..e5c2ac91 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,18 +1,18 @@ + android:background="#E46C62"/> + android:layout_above="@+id/layout_control" android:background="#E46C62" android:layout_marginBottom="12dp"> - + android:id="@+id/layout_control_accessibility_text" android:layout_margin="5dp" + android:textColor="#dfaa6a"/> + android:id="@+id/textView3" android:layout_margin="5dp" android:textColor="#858585"/> + android:background="#ffffff" android:layout_marginTop="8dp" android:layout_marginBottom="8dp" + android:onClick="openGitHub" android:layout_alignParentBottom="false" + android:layout_above="@+id/layout_admob_main"> @@ -127,4 +130,18 @@ android:id="@+id/textView9" android:layout_margin="2dp" android:textColor="#858585" android:layout_gravity="center_vertical"/> + + + + + diff --git a/app/src/main/res/layout/activity_webview.xml b/app/src/main/res/layout/activity_webview.xml index 825a6f7a..74f7df23 100644 --- a/app/src/main/res/layout/activity_webview.xml +++ b/app/src/main/res/layout/activity_webview.xml @@ -2,6 +2,7 @@ @@ -39,9 +40,22 @@ android:src="@mipmap/ic_open_in_browser" android:layout_alignParentRight="true" android:layout_marginLeft="8dp" android:padding="8dp"/> - + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index efa6a7d4..c1a4afc7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,4 +15,6 @@ 不拆开包含这些文字的红包(空格间隔) 随机选择下列感谢语(空格间隔) https://github.com/geeeeeeeeek/WeChatLuckyMoney/issues + ca-app-pub-8428619221469478/4736153346 + ca-app-pub-8428619221469478/4163694548 \ No newline at end of file diff --git a/build.gradle b/build.gradle index e82f6303..41449126 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' + classpath 'com.android.tools.build:gradle:2.2.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c7ad0812..a75b41db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jun 09 22:51:09 CST 2016 +#Sat Jan 21 16:40:37 CST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip