Skip to content

Commit

Permalink
Typo fixes, toasts -> snackbars, open permission settings after user …
Browse files Browse the repository at this point in the history
…presses "never ask again"
  • Loading branch information
apsun committed May 10, 2017
1 parent f5b0090 commit 4b44ff9
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 88 deletions.
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath "com.android.tools.build:gradle:2.3.0"
classpath "com.android.tools.build:gradle:2.3.1"
}
}

Expand All @@ -15,23 +15,23 @@ repositories {
apply plugin: "com.android.application"

dependencies {
compile "com.android.support:support-compat:25.3.0"
compile "com.android.support:support-core-ui:25.3.0"
compile "com.android.support:appcompat-v7:25.3.0"
compile "com.android.support:recyclerview-v7:25.3.0"
compile "com.android.support:support-annotations:25.3.0"
compile "com.android.support:design:25.3.0"
compile "com.android.support:support-compat:25.3.1"
compile "com.android.support:support-core-ui:25.3.1"
compile "com.android.support:appcompat-v7:25.3.1"
compile "com.android.support:recyclerview-v7:25.3.1"
compile "com.android.support:support-annotations:25.3.1"
compile "com.android.support:design:25.3.1"
compile "com.crossbowffs.remotepreferences:remotepreferences:0.5"
provided "de.robv.android.xposed:api:53"
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"

defaultConfig {
versionCode 28
versionName "0.14.0-dev"
versionCode 29
versionName "0.14.0"
minSdkVersion 19
targetSdkVersion 25
resConfigs "en", "zh-rCN"
Expand Down
29 changes: 15 additions & 14 deletions res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<string name="undo">撤消</string>
<string name="cancel">取消</string>
<string name="share">分享</string>
<string name="retry">重试</string>

<!-- Navigation drawer -->
<string name="open_drawer">扩展导航抽屉</string>
Expand All @@ -25,7 +26,7 @@
<string name="import_from_storage">从外部存储导入</string>
<string name="export_to_storage">导出到外部存储</string>
<string name="import_choose_file">选择备份文件</string>
<string name="import_confirm_title">导入备份?</string>
<string name="import_confirm_title">导入此备份?</string>
<string name="import_confirm_message">此操作会覆盖当前所有的过滤规则!</string>
<string name="export_file_name">备份文件名</string>
<string name="import_success">导入成功</string>
Expand All @@ -44,8 +45,8 @@
<!-- Filter rules -->
<string name="blacklist_rules">黑名单规则</string>
<string name="whitelist_rules">白名单规则</string>
<string name="blacklist_rules_empty_text">没有黑名单规则,来创建一条吧!</string>
<string name="whitelist_rules_empty_text">没有白名单规则,来创建一条吧!</string>
<string name="blacklist_rules_empty_text">没有任何黑名单规则!</string>
<string name="whitelist_rules_empty_text">没有任何白名单规则!</string>
<string name="format_filter_info">%1$s%2$s%3$s</string>
<string name="filter_info_field_sender">发送者</string>
<string name="filter_info_field_body">文本</string>
Expand All @@ -61,18 +62,18 @@
<string name="enable_xposed_module_title">启用Xposed模块</string>
<string name="enable_xposed_module_message">
Android 4.4以上不允许非默认的短信应用拦截信息或写入信息收件箱。\n
\n为了绕过此限制,请先启用NekoSMS的Xposed模块。否则,此应用将无法正常工作
\n为了绕过此限制,请启用NekoSMS的Xposed模块,否则此应用将无法工作
</string>
<string name="module_outdated_title">Xposed模块已更新</string>
<string name="module_outdated_message">请重启你的设备以使更改生效。</string>
<string name="task_killer_title">已检测到进程阻止应用</string>
<string name="task_killer_message">
在设备上已检测到了下列应用:\n
在设备上检测到了下列应用:\n
\n%s\n
\n请将NekoSMS加到白名单上。否则,此应用将无法正常工作
\n请将NekoSMS加到白名单上,否则此应用将无法工作
</string>
<string name="task_killer_ok">我明白了</string>
<string name="xposed_not_installed">未安装Xposed</string>
<string name="xposed_not_installed">Xposed未安装</string>
<string name="format_about_message">
<![CDATA[
基于表达式的Android短信拦截器<br><br>
Expand All @@ -96,17 +97,17 @@
<string name="invalid_pattern_reason_unknown">¯\\_(ツ)_/¯</string>

<!-- Blocked messages -->
<string name="blocked_messages">已拦截信息</string>
<string name="blocked_messages_empty_text">没有已拦截的信息!祝您今天愉快!</string>
<string name="blocked_messages">已拦截的信息</string>
<string name="blocked_messages_empty_text">没有任何垃圾信息!</string>
<string name="must_enable_xposed_module">需要启用Xposed模块</string>
<string name="clear_blocked_messages">清空拦截信息</string>
<string name="clear_blocked_messages">清空已拦截的信息</string>
<string name="confirm_clear_messages_title">删除所有信息?</string>
<string name="confirm_clear_messages_message">信息被删除后永远无法恢复!</string>
<string name="cleared_blocked_messages">已删除所有信息</string>
<string name="message_deleted">信息已删除</string>
<string name="message_restored">信息已恢复到收件箱</string>
<string name="message_delete_failed">信息无法删除</string>
<string name="message_restore_failed">信息无法恢复</string>
<string name="message_delete_failed">无法删除信息</string>
<string name="message_restore_failed">无法恢复信息</string>
<string name="load_blocked_message_failed">无法加载信息</string>
<string name="message_actions">信息操作</string>
<string name="format_message_details">
Expand Down Expand Up @@ -141,7 +142,7 @@
<string name="settings">设置</string>
<string name="pref_general">通用</string>
<string name="pref_enable">启用NekoSMS</string>
<string name="pref_enable_summary">拦截那些恼人的垃圾信息!</string>
<string name="pref_enable_summary">用此开关不需要重启</string>
<string name="pref_enable_summary_alt">请先启用Xposed模块!</string>
<string name="pref_whitelist_contacts">联系人白名单</string>
<string name="pref_whitelist_contacts_summary">不拦截来自联系人的信息</string>
Expand All @@ -167,7 +168,7 @@
<!-- App shortcuts -->
<string name="shortcut_new_blacklist_rule">新建黑名单规则</string>
<string name="shortcut_new_whitelist_rule">新建白名单规则</string>
<string name="shortcut_blocked_messages">已拦截信息</string>
<string name="shortcut_blocked_messages">已拦截的信息</string>

<!-- Debug stuff -->
<string name="create_test_message">创建测试信息</string>
Expand Down
19 changes: 10 additions & 9 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<string name="undo">Undo</string>
<string name="cancel">Cancel</string>
<string name="share">Share</string>
<string name="retry">Retry</string>

<!-- Navigation drawer -->
<string name="open_drawer">Open navigation drawer</string>
Expand Down Expand Up @@ -44,8 +45,8 @@
<!-- Filter rules -->
<string name="blacklist_rules">Blacklist rules</string>
<string name="whitelist_rules">Whitelist rules</string>
<string name="blacklist_rules_empty_text">No blacklist rules! Go ahead, create one!</string>
<string name="whitelist_rules_empty_text">No whitelist rules! Go ahead, create one!</string>
<string name="blacklist_rules_empty_text">No blacklist rules yet!</string>
<string name="whitelist_rules_empty_text">No whitelist rules yet!</string>
<string name="format_filter_info">%1$s %2$s%3$s</string>
<string name="filter_info_field_sender">Sender</string>
<string name="filter_info_field_body">Body</string>
Expand All @@ -68,8 +69,8 @@
<string name="module_outdated_message">Please reboot your device for changes to take effect.</string>
<string name="task_killer_title">Task killer apps detected</string>
<string name="task_killer_message">
The following apps have been detected on your device:\n\n%s\n\nPlease
make sure to whitelist NekoSMS, or else this app will not work!
The following apps have been detected on your device:\n\n%s\n
\nPlease whitelist NekoSMS, or else this app will not work!
</string>
<string name="task_killer_ok">I understand</string>
<string name="xposed_not_installed">Xposed not installed</string>
Expand Down Expand Up @@ -97,7 +98,7 @@

<!-- Blocked messages -->
<string name="blocked_messages">Blocked messages</string>
<string name="blocked_messages_empty_text">No blocked messages! Have a nice day!</string>
<string name="blocked_messages_empty_text">No blocked messages!</string>
<string name="must_enable_xposed_module">Xposed module must be enabled</string>
<string name="clear_blocked_messages">Clear blocked messages</string>
<string name="confirm_clear_messages_title">Delete all messages?</string>
Expand Down Expand Up @@ -141,13 +142,13 @@
<string name="settings">Settings</string>
<string name="pref_general">General</string>
<string name="pref_enable">Enable NekoSMS</string>
<string name="pref_enable_summary">Block those annoying SMS messages!</string>
<string name="pref_enable_summary_alt">You must enable the Xposed module first!</string>
<string name="pref_enable_summary">No reboot required</string>
<string name="pref_enable_summary_alt">Please enable the Xposed module first!</string>
<string name="pref_whitelist_contacts">Whitelist contacts</string>
<string name="pref_whitelist_contacts_summary">Do not block messages from contacts</string>
<string name="pref_whitelist_contacts_summary">Don\'t block messages from contacts</string>
<string name="pref_notifications">Notifications</string>
<string name="pref_notifications_enable">Enable notifications</string>
<string name="pref_notifications_enable_summary">Display a notification when a message is blocked</string>
<string name="pref_notifications_enable_summary">Display notification when a message is blocked</string>
<string name="pref_notifications_ringtone">Ringtone</string>
<string name="pref_notifications_ringtone_none">None</string>
<string name="pref_notifications_vibrate">Vibration</string>
Expand Down
14 changes: 8 additions & 6 deletions src/com/crossbowffs/nekosms/app/BlockedMessagesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private void clearAllMessages() {
if (context == null) return;

BlockedSmsLoader.get().deleteAll(context);
showToast(R.string.cleared_blocked_messages);
showSnackbar(R.string.cleared_blocked_messages);
}

private void showConfirmClearDialog() {
Expand Down Expand Up @@ -167,7 +167,7 @@ private void showMessageDetailsDialog(Uri uri) {
showMessageDetailsDialog(messageData);
} else {
// This can occur if the user deletes the message, then opens the notification
showToast(R.string.load_blocked_message_failed);
showSnackbar(R.string.load_blocked_message_failed);
}
}

Expand Down Expand Up @@ -206,8 +206,9 @@ public void onClick(DialogInterface dialog, int which) {
private void startXposedActivity(XposedUtils.Section section) {
Context context = getContext();
if (context == null) return;

if (!XposedUtils.startXposedActivity(context, section)) {
showToast(R.string.xposed_not_installed);
showSnackbar(R.string.xposed_not_installed);
}
}

Expand All @@ -229,7 +230,7 @@ public void onClick(View v) {
final SmsMessageData messageData = BlockedSmsLoader.get().query(context, smsId);
if (messageData == null) {
Xlog.e("Failed to restore message: could not load data");
showToast(R.string.load_blocked_message_failed);
showSnackbar(R.string.load_blocked_message_failed);
return;
}

Expand All @@ -238,7 +239,7 @@ public void onClick(View v) {
inboxSmsUri = InboxSmsLoader.writeMessage(context, messageData);
} catch (DatabaseException e) {
Xlog.e("Failed to restore message: could not write to SMS inbox");
showToast(R.string.message_restore_failed);
showSnackbar(R.string.message_restore_failed);
return;
}

Expand All @@ -259,10 +260,11 @@ public void onClick(View v) {
private void deleteSms(long smsId) {
Context context = getContext();
if (context == null) return;

final SmsMessageData messageData = BlockedSmsLoader.get().queryAndDelete(context, smsId);
if (messageData == null) {
Xlog.e("Failed to delete message: could not load data");
showToast(R.string.load_blocked_message_failed);
showSnackbar(R.string.load_blocked_message_failed);
return;
}

Expand Down
29 changes: 21 additions & 8 deletions src/com/crossbowffs/nekosms/app/FilterRulesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void onNewArguments(Bundle args) {
// a content:// URI would be used instead.
if (ContentResolver.SCHEME_FILE.equals(importUri.getScheme())) {
mPendingImportUri = importUri;
requestPermissionsCompat(Manifest.permission.READ_EXTERNAL_STORAGE, IMPORT_BACKUP_DIRECT_REQUEST);
requestPermissionsCompat(Manifest.permission.READ_EXTERNAL_STORAGE, IMPORT_BACKUP_DIRECT_REQUEST, false);
} else {
showConfirmImportDialog(importUri);
}
Expand Down Expand Up @@ -173,9 +173,14 @@ public void onLoaderReset(Loader<Cursor> loader) {
}

@Override
public void onRequestPermissionsResult(int requestCode, boolean granted) {
public void onRequestPermissionsResult(final int requestCode, boolean granted) {
if (!granted) {
showToast(R.string.need_storage_permission);
showSnackbar(R.string.need_storage_permission, R.string.retry, new View.OnClickListener() {
@Override
public void onClick(View v) {
requestStoragePermissions(requestCode, true);
}
});
} else if (requestCode == IMPORT_BACKUP_REQUEST) {
showImportFileSelectionDialog();
} else if (requestCode == EXPORT_BACKUP_REQUEST) {
Expand All @@ -186,6 +191,14 @@ public void onRequestPermissionsResult(int requestCode, boolean granted) {
}
}

private void requestStoragePermissions(int request, boolean openSettings) {
if (request == IMPORT_BACKUP_REQUEST) {
requestPermissionsCompat(Manifest.permission.READ_EXTERNAL_STORAGE, IMPORT_BACKUP_REQUEST, openSettings);
} else if (request == EXPORT_BACKUP_REQUEST) {
requestPermissionsCompat(Manifest.permission.WRITE_EXTERNAL_STORAGE, EXPORT_BACKUP_REQUEST, openSettings);
}
}

private void showImportExportDialog() {
CharSequence[] items = {getString(R.string.import_from_storage), getString(R.string.export_to_storage)};
new AlertDialog.Builder(getContext())
Expand All @@ -194,9 +207,9 @@ private void showImportExportDialog() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
requestPermissionsCompat(Manifest.permission.READ_EXTERNAL_STORAGE, IMPORT_BACKUP_REQUEST);
requestStoragePermissions(IMPORT_BACKUP_REQUEST, false);
} else if (which == 1) {
requestPermissionsCompat(Manifest.permission.WRITE_EXTERNAL_STORAGE, EXPORT_BACKUP_REQUEST);
requestStoragePermissions(EXPORT_BACKUP_REQUEST, false);
}
}
})
Expand All @@ -206,7 +219,7 @@ public void onClick(DialogInterface dialog, int which) {
private void showImportFileSelectionDialog() {
final File[] files = BackupLoader.enumerateBackupFiles();
if (files == null || files.length == 0) {
showToast(R.string.import_no_backup);
showSnackbar(R.string.import_no_backup);
return;
}

Expand Down Expand Up @@ -301,7 +314,7 @@ protected void onPostExecute(ImportResult result) {
default:
throw new AssertionError("Unknown backup import result code: " + result);
}
showToast(messageId);
showSnackbar(messageId);
}
}.execute();
}
Expand Down Expand Up @@ -338,7 +351,7 @@ public void onClick(View v) {
}
});
} else {
showToast(messageId);
showSnackbar(messageId);
}
}
}.execute();
Expand Down
Loading

0 comments on commit 4b44ff9

Please sign in to comment.