Skip to content

Commit

Permalink
feat:adapter android N
Browse files Browse the repository at this point in the history
  • Loading branch information
maoruibin committed Feb 3, 2017
1 parent 7ff6203 commit 41709ad
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 17 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ apply plugin:'im.fir.plugin.gradle'

fir{
apiToken '15e5206706b555384608e449d6def6d3'
changeLog '* add upload plugin for fir\n' +
'* add changelog file'
changeLog 'adapter quick setting for Android N version'
}

bughd{
Expand Down
34 changes: 22 additions & 12 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@
android:name="BUG_HD_SDK_GENERAL_KEY"
android:value="60641333d73c37d9db66465ab8f78cc9" />

<!--android:theme="@android:style/Theme.NoDisplay"-->
<!--android:theme="@android:style/Theme.Dialog"-->
<!-- android:theme="@android:style/Theme.NoDisplay" -->
<!-- android:theme="@android:style/Theme.Dialog" -->
<activity
android:name=".ui.activitys.ProcessTextActivity"
android:label="@string/app_process_text"
android:theme="@style/myTransparent">
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
</intent-filter>
</activity>

<activity android:name=".ui.activitys.MainActivity"
<activity
android:name=".ui.activitys.MainActivity"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -62,7 +64,7 @@
android:name=".listener.ListenClipboardService"
android:enabled="true"
android:label="@string/app_process_text"
android:process=":process"/>
android:process=":process" />

<receiver
android:name=".listener.BootCompletedReceiver"
Expand All @@ -74,21 +76,29 @@
</receiver>

<activity android:name=".ui.activitys.WordsBookActivity" />

<activity android:name=".ui.activitys.SettingActivity" />

<receiver android:name=".listener.AlarmReceiver">
<intent-filter>
<action android:name="name.gudong.translate.alarm"/>
<action android:name="name.gudong.translate.alarm" />
</intent-filter>
</receiver>

<!--<receiver android:name=".service.KeepAlarmLiveReceiver">-->
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.USER_PRESENT"/>-->
<!--</intent-filter>-->
<!--</receiver>-->
<!-- <receiver android:name=".service.KeepAlarmLiveReceiver"> -->
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.USER_PRESENT"/> -->
<!-- </intent-filter> -->
<!-- </receiver> -->

<service
android:name=".service.QuickSettingService"
android:icon="@drawable/icon_notification"
android:label="@string/quick_setting"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
</application>

</manifest>
3 changes: 2 additions & 1 deletion app/src/main/assets/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@
咕咚翻译 - 一个实现手机端『划词翻译』功能的 App,可能是目前 Android 市场上翻译效率最高的应用。
</p>

<h3>Version 1.3.6</h3>
<h3>Version 1.3.7</h3>

<ol>
<li><b>优化:</b> 为 6.0 设备增加悬浮窗权限申请,解决 MIUI 等部分设备需要手动开启权限的问题</li>
<li><b>新增:</b> 适配 Android N 快速开关(2017-02-04)</li>
<li><b>新增:</b> 咕咚翻译可以背收藏的生词了,好词就应该死里记(10-01)</li>
<li><b>新增:</b> 咕咚翻译中可以看到每日一句了(10-07)</li>
<li><b>新增:</b> 适配 Android M 增加快捷查词(10-06)</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package name.gudong.translate.service;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.Log;

import name.gudong.translate.listener.ListenClipboardService;
import name.gudong.translate.manager.ReciteModulePreference;

@TargetApi(Build.VERSION_CODES.N)
public class QuickSettingService extends TileService {
private static final String TAG = "QuickSettingService";
ReciteModulePreference mRecitePreference;

@Override
public void onCreate() {
super.onCreate();
mRecitePreference = new ReciteModulePreference(getBaseContext());
}


@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if(getQsTile() == null){
return super.onStartCommand(intent, flags, startId);
}
if(mRecitePreference.isReciteOpenOrNot()){
getQsTile().setState(Tile.STATE_ACTIVE);// 更改成非活跃状态
}else{
getQsTile().setState(Tile.STATE_INACTIVE);// 更改成非活跃状态
}
return super.onStartCommand(intent, flags, startId);
}

@Override
public void onClick() {
int state = getQsTile().getState();
Log.d(TAG, "onClick state = " + Integer.toString(getQsTile().getState()));
if (state == Tile.STATE_INACTIVE) {
getQsTile().setState(Tile.STATE_ACTIVE);// 更改成活跃状态
mRecitePreference.setReciteOpenOrNot(true);
} else {
getQsTile().setState(Tile.STATE_INACTIVE);//更改成非活跃状态
mRecitePreference.setReciteOpenOrNot(false);
}
getQsTile().updateTile();//更新Tile
shiftRecite();
}

private void shiftRecite() {
//利用 Service 生命周期巧妙控制开关
ListenClipboardService.start(getBaseContext());
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="menu_score">去评分</string>
<string name="menu_support">支持作者</string>

<string name="quick_setting">背单词</string>
<string name="use_recite_or_nor">开启定时单词提醒</string>
<string name="open_jit_or_nor">开启划词翻译</string>
<string name="notify_dayline">开启每日一句提醒</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<string name="menu_score">去评分</string>
<string name="menu_support">支持作者</string>

<string name="quick_setting">recite words</string>
<string name="use_recite_or_nor">开启定时单词提醒</string>
<string name="open_jit_or_nor">开启划词翻译</string>
<string name="notify_dayline">开启每日一句提醒</string>
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ext {
minSdk : 16,
minSdk21 : 21,
targetSdk : 24,
version_code : 136,
version_name : "1.3.6"
version_code : 137,
version_name : "1.3.7"
]

libraries = [
Expand Down
4 changes: 4 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2017/02/04

* adapter quick setting for Android N version

## 2017/01/24

* add upload plugin for fir
Expand Down

0 comments on commit 41709ad

Please sign in to comment.