liuyuqi-dellpc 6 years ago
parent
commit
794afe900f

+ 18 - 1
app/src/main/AndroidManifest.xml

@@ -31,7 +31,24 @@
             android:theme="@style/Base.Theme.AppCompat.Light"></activity>
         <activity android:name=".activities.WebViewActivity"
             android:theme="@style/Base.Theme.AppCompat.Light"></activity>
-        <service android:name=".services.HongbaoService"></service>
+        <service
+            android:name=".services.HongbaoService"
+            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
+            <intent-filter>
+                <action android:name="android.accessibilityservice.AccessibilityService"/>
+            </intent-filter>
+            <meta-data android:name="android.accessibilityservice"
+                android:resource="@xml/accessible_service_config"/>
+        </service>
+        <provider
+            android:name="android.support.v4.content.FileProvider"
+            android:authorities="xyz.monkeytong.hongbao.fileProvider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/provider_paths"/>
+        </provider>
     </application>
 
 </manifest>

+ 9 - 16
app/src/main/java/me/yoqi/app/wxredpacket/activities/MainActivity.java

@@ -50,6 +50,9 @@ public class MainActivity extends Activity implements AccessibilityManager.Acces
         updateServiceStatus();
     }
 
+    /**
+     * 设置默认偏好
+     */
     private void explicitlyLoadPreferences() {
         PreferenceManager.setDefaultValues(this, R.xml.general_preferences, false);
     }
@@ -94,6 +97,9 @@ public class MainActivity extends Activity implements AccessibilityManager.Acces
         super.onDestroy();
     }
 
+    /**跳转到辅助服务设置界面点击事件
+     * @param view
+     */
     public void openAccessibility(View view) {
         try {
             Toast.makeText(this, getString(R.string.turn_on_toast) + pluginStatusText.getText(), Toast.LENGTH_SHORT).show();
@@ -106,22 +112,9 @@ public class MainActivity extends Activity implements AccessibilityManager.Acces
 
     }
 
-    public void openGitHub(View view) {
-        Intent webViewIntent = new Intent(this, WebViewActivity.class);
-        webViewIntent.putExtra("title", getString(R.string.webview_github_title));
-        webViewIntent.putExtra("url", "https://github.com/geeeeeeeeek/WeChatLuckyMoney");
-        startActivity(webViewIntent);
-    }
-
-    public void openUber(View view) {
-        Intent webViewIntent = new Intent(this, WebViewActivity.class);
-        webViewIntent.putExtra("title", getString(R.string.webview_uber_title));
-        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);
-    }
-
+    /**设置点击事件
+     * @param view
+     */
     public void openSettings(View view) {
         Intent settingsIntent = new Intent(this, SettingsActivity.class);
         settingsIntent.putExtra("title", getString(R.string.preference));

+ 1 - 0
app/src/main/java/me/yoqi/app/wxredpacket/activities/SettingsActivity.java

@@ -39,6 +39,7 @@ public class SettingsActivity extends FragmentActivity {
         String title, fragId;
         Bundle bundle = getIntent().getExtras();
         if (bundle != null) {
+            //从bundle获取传递的参数。
             title = bundle.getString("title");
             fragId = bundle.getString("frag_id");
         } else {

+ 7 - 2
app/src/main/java/me/yoqi/app/wxredpacket/activities/WebViewActivity.java

@@ -21,8 +21,7 @@ import me.yoqi.app.wxredpacket.R;
 import me.yoqi.app.wxredpacket.utils.DownloadUtil;
 
 /**
- * Created by Zhongyi on 1/19/16.
- * Settings page.
+ * webview打开网页
  */
 public class WebViewActivity extends Activity {
     private WebView webView;
@@ -88,6 +87,9 @@ public class WebViewActivity extends Activity {
         super.onDestroy();
     }
 
+    /**
+     * 加载UI
+     */
     @TargetApi(Build.VERSION_CODES.LOLLIPOP)
     private void loadUI() {
         setContentView(R.layout.activity_webview);
@@ -124,6 +126,9 @@ public class WebViewActivity extends Activity {
         return super.onKeyDown(keyCode, event);
     }
 
+    /**打开链接
+     * @param view
+     */
     public void openLink(View view) {
         Intent intent = new Intent(Intent.ACTION_VIEW,
                 Uri.parse(this.webViewUrl));

+ 45 - 147
app/src/main/res/layout/activity_main.xml

@@ -28,7 +28,8 @@
             android:text="@string/app_name"
             android:textColor="#fff"
             android:textIsSelectable="false"
-            android:textSize="28dp" />
+            android:textSize="28dp"
+            tools:text="wxRedPacket" />
         <TextView android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:id="@+id/textView5"
@@ -43,40 +44,18 @@
             android:background="@mipmap/bg_snow"
             android:id="@+id/main_bg_snow"
             android:layout_alignBottom="@id/layout_header"/>
-    <LinearLayout android:id="@+id/layout_control"
-                  android:orientation="horizontal"
-                  android:layout_width="match_parent"
-                  android:layout_height="110dp"
-                  android:layout_above="@+id/layout_uber"
-                  android:layout_marginLeft="12dp"
-                  android:layout_marginRight="12dp"
-                  android:layout_marginTop="8dp"
-                  android:layout_marginBottom="8dp" android:baselineAligned="false">
-        <LinearLayout style="?android:attr/borderlessButtonStyle"
-                      android:id="@+id/layout_control_community"
-                      android:layout_width="fill_parent"
-                      android:layout_height="fill_parent"
-                      android:background="#ffffff"
-                      android:textColor="#858585"
-                      android:textSize="20sp"
-                      android:orientation="vertical"
-                      android:layout_weight="0.35"
-                      android:layout_marginRight="5dp"
-                      android:onClick="openGitHub" android:layout_marginEnd="5dp">
-            <ImageView
-                    android:layout_width="24dp"
-                    android:layout_height="24dp"
-                    android:id="@+id/imageView"
-                    android:src="@mipmap/ic_community"
-                    android:layout_margin="10dp"/>
-            <TextView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/community"
-                    android:id="@+id/textView2"
-                    android:layout_margin="5dp"
-                    android:textColor="#858585" android:textSize="16sp" android:textStyle="bold"/>
-        </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/layout_control"
+        android:layout_width="match_parent"
+        android:layout_height="110dp"
+        android:layout_alignParentBottom="true"
+        android:layout_marginBottom="20dp"
+        android:layout_marginLeft="12dp"
+        android:layout_marginRight="12dp"
+        android:layout_marginTop="8dp"
+        android:baselineAligned="false"
+        android:orientation="horizontal">
 
         <LinearLayout
             android:id="@+id/layout_control_accessibility"
@@ -85,7 +64,7 @@
             android:layout_height="fill_parent"
             android:layout_marginLeft="5dp"
             android:layout_marginRight="5dp"
-            android:layout_weight="0.3"
+            android:layout_weight="0.5"
             android:background="#ffffff"
             android:onClick="openAccessibility"
             android:textColor="#858585"
@@ -110,119 +89,38 @@
                 android:textSize="16sp"
                 android:textStyle="bold" />
         </LinearLayout>
-        <LinearLayout style="?android:attr/borderlessButtonStyle"
-                      android:id="@+id/layout_control_settings"
-                      android:layout_width="fill_parent"
-                      android:layout_height="fill_parent"
-                      android:background="#ffffff"
-                      android:textColor="#858585"
-                      android:textSize="20sp"
-                      android:orientation="vertical"
-                      android:layout_weight="0.35"
-                      android:layout_marginLeft="5dp"
-                      android:onClick="openSettings" android:layout_marginStart="5dp">
-            <ImageView android:layout_width="24dp"
-                       android:layout_height="24dp"
-                       android:id="@+id/imageView4"
-                       android:layout_margin="10dp"
-                       android:src="@mipmap/ic_settings"/>
-            <TextView android:layout_width="wrap_content"
-                      android:layout_height="wrap_content"
-                      android:text="@string/settings"
-                      android:id="@+id/textView3"
-                      android:layout_margin="5dp"
-                      android:textColor="#858585" android:textSize="16sp" android:textStyle="bold"/>
-        </LinearLayout>
-    </LinearLayout>
-    <LinearLayout
-            android:id="@+id/layout_uber"
-            android:orientation="horizontal"
-            android:layout_width="match_parent"
-            android:layout_height="72dp"
-            android:layout_marginLeft="12dp"
-            android:layout_marginRight="12dp"
-            android:background="#ffffff"
-            android:layout_marginTop="8dp"
-            android:layout_alignParentBottom="false"
-            android:layout_above="@+id/linearLayout2"
-            android:layout_marginBottom="8dp"
-            android:onClick="openUber">
-        <ImageView
-                android:layout_width="60dp"
-                android:layout_height="60dp"
-                android:id="@+id/icon_uber"
-                android:src="@mipmap/ic_uber"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="10dp"
-                android:layout_gravity="center_vertical"
-                android:layout_marginBottom="2dp" android:layout_marginStart="8dp" android:layout_marginEnd="10dp"/>
+
         <LinearLayout
-                android:orientation="vertical"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:id="@+id/layout_uber_text"
-                android:layout_gravity="center_vertical">
+            android:id="@+id/layout_control_settings"
+            style="?android:attr/borderlessButtonStyle"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:layout_marginLeft="5dp"
+            android:layout_marginStart="5dp"
+            android:layout_weight="0.5"
+            android:background="#ffffff"
+            android:onClick="openSettings"
+            android:orientation="vertical"
+            android:textColor="#858585"
+            android:textSize="20sp">
+
+            <ImageView
+                android:id="@+id/imageView4"
+                android:layout_width="24dp"
+                android:layout_height="24dp"
+                android:layout_margin="10dp"
+                android:src="@mipmap/ic_settings" />
+
             <TextView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/uber_ad_title"
-                    android:id="@+id/label_uber_text"
-                    android:layout_margin="2dp"
-                    android:textColor="#858585"/>
-            <TextView android:layout_width="wrap_content"
-                      android:layout_height="wrap_content"
-                      android:text="@string/uber_ad_text"
-                      android:id="@+id/label_uber_link"
-                      android:layout_margin="2dp"
-                      android:textColor="#dfaa6a" android:textStyle="bold"/>
+                android:id="@+id/textView3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_margin="5dp"
+                android:text="@string/settings"
+                android:textColor="#858585"
+                android:textSize="16sp"
+                android:textStyle="bold" />
         </LinearLayout>
     </LinearLayout>
-    <LinearLayout android:id="@+id/linearLayout2"
-                  android:orientation="horizontal"
-                  android:layout_width="match_parent"
-                  android:layout_height="40dp"
-                  android:layout_marginLeft="12dp"
-                  android:layout_marginRight="12dp"
-                  android:background="#ffffff"
-                  android:layout_marginTop="8dp"
-                  android:layout_marginBottom="24dp"
-                  android:onClick="openGitHub"
-                  android:layout_alignParentBottom="true">
-        <ImageView android:layout_width="20dp"
-                   android:layout_height="20dp"
-                   android:id="@+id/imageView2"
-                   android:src="@mipmap/ic_github"
-                   android:layout_marginLeft="15dp"
-                   android:layout_marginRight="5dp"
-                   android:layout_gravity="center_vertical" android:layout_marginStart="15dp" android:layout_marginEnd="5dp"/>
-        <TextView android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:text="@string/github_1"
-                  android:id="@+id/textView6"
-                  android:layout_margin="2dp"
-                  android:textColor="#858585"
-                  android:layout_gravity="center_vertical"/>
-        <TextView android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:text="@string/star_1"
-                  android:id="@+id/textView7"
-                  android:textColor="#dfaa6a"
-                  android:layout_gravity="center_vertical"
-                  android:paddingBottom="1dp"/>
-        <TextView android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:id="@+id/textView8"
-                  android:text="@string/star_2"
-                  android:textColor="#dfaa6a"
-                  android:layout_gravity="center_vertical"
-                  android:layout_marginLeft="2dp"
-                  android:layout_marginRight="2dp" android:textStyle="bold"/>
-        <TextView android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:text="@string/github_2"
-                  android:id="@+id/textView9"
-                  android:layout_margin="2dp"
-                  android:textColor="#858585"
-                  android:layout_gravity="center_vertical"/>
-    </LinearLayout>
+
 </RelativeLayout>

+ 1 - 1
app/src/main/res/values-en/strings.xml

@@ -2,7 +2,7 @@
 <resources>
     <string name="app_name">wxRedPacket</string>
     <string name="app_version">v1.0</string>
-    <string name="app_description">∠( ᐛ 」∠)_ Instructions ∠( ᐛ 」∠)_\n\n ○ Turn on the Accessibility switch\n ○ Go back to WeChat\n ○ Wait for money comes in\n\n Please submit your feedback on GitHub Issues Page~\n https://github.com/geeeeeeeeek/WeChatLuckyMoney</string>
+    <string name="app_description">Instructions\n\n ○ Turn on the Accessibility switch\n ○ Go back to WeChat\n ○ Wait for money comes in</string>
     <string name="preference">Preferences</string>
     <string name="update_error">An error occurred. Please manually update from GitHub Release Page. (ฅ´ω`ฅ)</string>
     <string name="update_new_seg1">New version found.(</string>

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -1,7 +1,7 @@
 <resources>
     <string name="app_name">微信红包</string>
     <string name="app_version">v1.0</string>
-    <string name="app_description">∠( ᐛ 」∠)_使用指南∠( ᐛ 」∠)_\n\n ○ 狠戳插件开关\n ○ 回到微信聊天\n ○ 坐等红包进账\n\n 遇到问题, 欢迎通过 GitHub Issue 反馈~\n https://github.com/geeeeeeeeek/WeChatLuckyMoney</string>
+    <string name="app_description">使用指南\n\n ○ 狠戳插件开关\n ○ 回到微信聊天\n ○ 坐等红包进账\n\n </string>
     <string name="preference">偏好设置</string>
     <string name="update_error">遇到一些问题,请前往GitHub手动更新喵(ฅ´ω`ฅ)</string>
     <string name="update_new_seg1">发现新版本(</string>

+ 1 - 1
app/src/main/res/xml/accessible_service_config.xml

@@ -6,6 +6,6 @@
     android:accessibilityFeedbackType="feedbackAllMask"
     android:packageNames="com.tencent.mm"
     android:notificationTimeout="10"
-    android:settingsActivity="xyz.monkeytong.hongbao.activities.SettingsActivity"
+    android:settingsActivity="me.yoqi.app.wxredpacket.activities.SettingsActivity"
     android:accessibilityFlags="flagDefault"
     android:canRetrieveWindowContent="true"/>

+ 1 - 1
app/src/main/res/xml/comment_preferences.xml

@@ -17,7 +17,7 @@
     <PreferenceCategory
             android:title="回复选项"
             android:layout="@layout/preference_category">
-        <xyz.monkeytong.hongbao.activities.SeekBarPreference
+        <me.yoqi.app.wxredpacket.activities.SeekBarPreference
                 android:key="pref_comment_delay"
                 android:title="延时发送回复"
                 pref_kind="pref_comment_delay"

+ 1 - 1
app/src/main/res/xml/general_preferences.xml

@@ -27,7 +27,7 @@
                 android:title="@string/auto_open_packets"
                 android:layout="@layout/preference_checkbox"
                 android:defaultValue="true"/>
-        <xyz.monkeytong.hongbao.activities.SeekBarPreference
+        <me.yoqi.app.wxredpacket.activities.SeekBarPreference
                 android:key="pref_open_delay"
                 android:title="@string/open_with_delay"
                 pref_kind="pref_open_delay"