Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 3887e88

Browse files
committed
Code cleanup, fix Wikiquote download failure
1 parent e847011 commit 3887e88

21 files changed

+210
-134
lines changed

AndroidManifest.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
<activity
1818
android:name=".modules.custom.app.CustomQuoteConfigActivity"
1919
android:label="@string/module_custom_activity_label"/>
20+
<activity
21+
android:name=".modules.brainyquote.app.BrainyQuoteConfigActivity"
22+
android:label="@string/module_brainy_activity_label"/>
2023
<provider
2124
android:name=".modules.custom.provider.CustomQuoteProvider"
2225
android:authorities="${applicationId}.modules.custom.provider"
2326
android:exported="false"/>
24-
<activity
25-
android:name=".modules.brainyquote.app.BrainyquoteQuoteConfigActivity"
26-
android:label="@string/module_brainyquote_activity_label" />
2727
<service
2828
android:name=".app.QuoteDownloaderService"
2929
android:permission="android.permission.BIND_JOB_SERVICE"/>

build.gradle

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,30 @@ repositories {
1515
apply plugin: "com.android.application"
1616

1717
dependencies {
18-
compile "com.crossbowffs.remotepreferences:remotepreferences:0.4"
19-
compile "org.jsoup:jsoup:1.9.2"
18+
compile "com.crossbowffs.remotepreferences:remotepreferences:0.5"
19+
compile "org.jsoup:jsoup:1.10.2"
2020
provided "de.robv.android.xposed:api:53"
2121
}
2222

2323
android {
24-
compileSdkVersion 23
25-
buildToolsVersion "24.0.2"
24+
compileSdkVersion 25
25+
buildToolsVersion "25.0.2"
2626

2727
defaultConfig {
28-
versionCode 10
29-
versionName "1.3.1"
28+
versionCode 11
29+
versionName "1.4.0"
3030
minSdkVersion 21
31+
32+
/*
33+
* QuoteLock is not compatible with API24 and above due to the
34+
* behavior changes in connectivity intents. If someone wants to
35+
* fix this, feel free, but be aware that JobScheduler is already
36+
* buggy enough as it is.
37+
*/
3138
targetSdkVersion 23
3239
buildConfigField("int", "MODULE_VERSION", "3")
3340
buildConfigField("int", "CUSTOM_QUOTES_DB_VERSION", "1")
41+
buildConfigField("String", "LOG_TAG", "\"QuoteLock\"")
3442
}
3543

3644
sourceSets {
@@ -41,4 +49,20 @@ android {
4149
assets.srcDir "assets"
4250
}
4351
}
52+
53+
buildTypes {
54+
debug {
55+
buildConfigField("int", "LOG_LEVEL", "2")
56+
buildConfigField("boolean", "LOG_TO_XPOSED", "false")
57+
}
58+
59+
release {
60+
buildConfigField("int", "LOG_LEVEL", "4")
61+
buildConfigField("boolean", "LOG_TO_XPOSED", "true")
62+
}
63+
}
64+
65+
lintOptions {
66+
abortOnError false
67+
}
4468
}
Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,52 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
android:orientation="horizontal"
4+
android:orientation="vertical"
55
android:layout_width="match_parent"
6-
android:layout_height="match_parent"
7-
>
8-
6+
android:layout_height="match_parent">
97
<RadioGroup
108
android:id="@+id/module_brainy_activity_radiogroup"
9+
android:checkedButton="@+id/module_brainy_activity_type_general"
1110
android:layout_width="match_parent"
1211
android:layout_height="match_parent"
13-
android:checkedButton="@+id/module_brainy_activity_type_general"
1412
android:divider="?android:attr/dividerHorizontal"
1513
android:showDividers="middle"
1614
android:paddingLeft="16dp"
17-
android:paddingRight="16dp" >
18-
15+
android:paddingRight="16dp">
1916
<RadioButton
2017
android:layout_width="match_parent"
2118
android:layout_height="0dp"
2219
android:layout_weight="1"
2320
android:id="@+id/module_brainy_activity_type_general"
2421
android:text="@string/module_brainy_activity_type_general"
25-
android:textAppearance="?android:attr/textAppearanceMedium" />
26-
22+
android:textAppearance="?android:attr/textAppearanceMedium"/>
2723
<RadioButton
2824
android:layout_width="match_parent"
2925
android:layout_height="0dp"
3026
android:layout_weight="1"
3127
android:id="@+id/module_brainy_activity_type_art"
3228
android:text="@string/module_brainy_activity_type_art"
33-
android:textAppearance="?android:attr/textAppearanceMedium" />
34-
29+
android:textAppearance="?android:attr/textAppearanceMedium"/>
3530
<RadioButton
3631
android:layout_width="match_parent"
3732
android:layout_height="0dp"
3833
android:layout_weight="1"
3934
android:id="@+id/module_brainy_activity_type_funny"
4035
android:text="@string/module_brainy_activity_type_funny"
41-
android:textAppearance="?android:attr/textAppearanceMedium" />
42-
36+
android:textAppearance="?android:attr/textAppearanceMedium"/>
4337
<RadioButton
4438
android:layout_width="match_parent"
4539
android:layout_height="0dp"
4640
android:layout_weight="1"
4741
android:id="@+id/module_brainy_activity_type_love"
4842
android:text="@string/module_brainy_activity_type_love"
49-
android:textAppearance="?android:attr/textAppearanceMedium" />
50-
43+
android:textAppearance="?android:attr/textAppearanceMedium"/>
5144
<RadioButton
5245
android:layout_width="match_parent"
5346
android:layout_height="0dp"
5447
android:layout_weight="1"
5548
android:id="@+id/module_brainy_activity_type_nature"
5649
android:text="@string/module_brainy_activity_type_nature"
57-
android:textAppearance="?android:attr/textAppearanceMedium" />
58-
50+
android:textAppearance="?android:attr/textAppearanceMedium"/>
5951
</RadioGroup>
60-
61-
</LinearLayout>
52+
</LinearLayout>

res/values/strings.xml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3+
<!-- Common strings -->
34
<string name="quotelock">QuoteLock</string>
5+
<string name="easter_egg">▲ + ▼ = ◆</string>
6+
47
<string name="edit">Edit</string>
58
<string name="delete">Delete</string>
69
<string name="enable">Enable</string>
@@ -10,6 +13,7 @@
1013
<string name="cancel">Cancel</string>
1114
<string name="settings">Settings</string>
1215
<string name="about">About</string>
16+
<string name="close">Close</string>
1317
<string name="enable_xposed_module_title">Enable Xposed module</string>
1418
<string name="enable_xposed_module_message">
1519
Android does not normally allow apps to add text to the lockscreen.\n\n
@@ -27,34 +31,59 @@
2731
<string name="pref_unmetered_only_summary">Don\'t update on metered connections</string>
2832
<string name="pref_unmetered_only_summary_alt">Selected provider does not require internet</string>
2933
<string name="pref_font_size_text_title">Quote font size</string>
30-
<string name="pref_font_size_text_summary">The size of the quote text</string>
34+
<string name="pref_font_size_text_summary">Size of the quote text</string>
3135
<string name="pref_font_size_source_title">Source font size</string>
32-
<string name="pref_font_size_source_summary">The size of the source text</string>
36+
<string name="pref_font_size_source_summary">Size of the source text</string>
3337
<string name="pref_quote_module_title">Quote provider</string>
3438
<string name="pref_quote_module_summary">Select a quote source</string>
3539
<string name="pref_module_preferences_title">Quote provider preferences</string>
3640
<string name="pref_module_preferences_summary">Manage provider-specific settings</string>
3741
<string name="pref_module_preferences_summary_alt">No preferences for selected provider</string>
38-
<string name="pref_about_author_crossbowffs">App and quote providers</string>
39-
<string name="pref_about_author_yubyf">Additional quote providers</string>
42+
<string name="pref_about_credits_title">Credits</string>
43+
<string name="pref_about_credits_summary">Who did what?</string>
4044
<string name="pref_about_github">View project on GitHub</string>
4145
<string name="pref_about_version">Version</string>
42-
<string name="pref_about_easter_egg">一回百円で心穏やかになれるのです…</string>
4346
<string name="refesh_quote">Refresh quote</string>
4447
<string name="downloading_quote">Downloading quote…</string>
4548
<string name="quote_download_failed">Failed to download quote</string>
4649
<string name="quote_download_success">Quote downloaded successfully</string>
4750
<string name="open_quotelock_app_line1">Welcome to QuoteLock!</string>
4851
<string name="open_quotelock_app_line2">Please open the configuration app</string>
4952
<string name="selected_module_not_found">Selected module could not be found</string>
53+
<string name="credits_title">Credits</string>
54+
<string name="credits_message">
55+
<![CDATA[
56+
<b>App development</b><br>
57+
- <a href="https://twitter.com/crossbowffs">crossbowffs</a><br>
58+
- <a href="https://github.com/Yubyf">Yubyf</a><br>
59+
- <a href="https://github.com/Hual">Hual</a><br>
60+
61+
<br><b>Quote providers</b><br>
62+
- <a href="http://vnaas.apsun.xyz/">Visual Novel as a Service</a><br>
63+
- <a href="https://blog.lwl12.com/read/hitokoto-api.html">Hitokoto</a><br>
64+
- <a href="http://www.goodreads.com/">Goodreads QotD</a><br>
65+
- <a href="https://www.wikiquote.org/">Wikiquote QotD</a><br>
66+
- <a href="https://freakuotes.com/">Freakuotes</a><br>
67+
- <a href="https://natune.net/zitate/">Natune.net</a><br>
68+
- <a href="https://www.brainyquote.com/">BrainyQuote</a><br>
69+
70+
<br><b>Libraries used</b><br>
71+
- <a href="https://jsoup.org/">Jsoup</a><br>
72+
- <a href="https://github.com/apsun/RemotePreferences">RemotePreferences</a>
73+
]]>
74+
</string>
75+
76+
<!-- Provider-specific strings -->
5077
<string name="module_vnaas_name">Visual Novel as a Service (日本語)</string>
5178
<string name="module_hitokoto_name">Hitokoto 一言 (中文)</string>
5279
<string name="module_goodreads_name">Goodreads QotD (English)</string>
53-
<string name="module_brainy_name">BrainyQuote (English)</string>
5480
<string name="module_wikiquote_name">Wikiquote QotD (中文)</string>
5581
<string name="module_freakuotes_name">Freakuotes (Español)</string>
5682
<string name="module_natune_name">Natune.net (Deutsch)</string>
83+
<string name="module_brainy_name">BrainyQuote (English)</string>
5784
<string name="module_custom_name">Custom</string>
85+
86+
<!-- Custom quotes -->
5887
<string name="module_custom_setup_line1">No custom quotes set</string>
5988
<string name="module_custom_setup_line2">Please open the provider settings</string>
6089
<string name="module_custom_activity_label">Custom quotes</string>
@@ -64,8 +93,9 @@
6493
<string name="module_custom_source">Source</string>
6594
<string name="module_custom_saved_quote">Saved quote</string>
6695
<string name="module_custom_deleted_quote">Deleted quote</string>
67-
<string name="module_brainyquote_activity_label">BrainyQuote setup</string>
68-
<string name="module_brainy_activity_hint">Quote type</string>
96+
97+
<!-- BrainyQuote -->
98+
<string name="module_brainy_activity_label">BrainyQuote setup</string>
6999
<string name="module_brainy_activity_type_general">QotD - General</string>
70100
<string name="module_brainy_activity_type_art">QotD - Art</string>
71101
<string name="module_brainy_activity_type_funny">QotD - Funny</string>

res/xml/settings.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@
4040
</PreferenceCategory>
4141
<PreferenceCategory android:title="@string/about">
4242
<Preference
43-
android:key="pref_about_author_crossbowffs"
44-
android:title="@string/pref_about_author_crossbowffs"
45-
android:summary="crossbowffs"/>
46-
<Preference
47-
android:key="pref_about_author_yubyf"
48-
android:title="@string/pref_about_author_yubyf"
49-
android:summary="Yubyf, Hual"/>
43+
android:key="pref_about_credits"
44+
android:title="@string/pref_about_credits_title"
45+
android:summary="@string/pref_about_credits_summary"/>
5046
<Preference
5147
android:key="pref_about_github"
5248
android:title="@string/pref_about_github"

src/com/crossbowffs/quotelock/api/QuoteData.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
package com.crossbowffs.quotelock.api;
22

3+
/**
4+
* Holds the data for a quote. Really just an overglorified
5+
* String tuple class.
6+
*/
37
public class QuoteData {
48
private final String mQuoteText;
59
private final String mQuoteSource;
610

11+
/**
12+
* Creates a new quote data object. The parameters may be {@code null},
13+
* in which case they are replaced with an empty string.
14+
*
15+
* @param quoteText The first line (text) of the quote.
16+
* @param quoteSource The second line (author) of the quote.
17+
*/
718
public QuoteData(String quoteText, String quoteSource) {
819
mQuoteText = quoteText;
920
mQuoteSource = quoteSource;
1021
}
1122

23+
/**
24+
* Gets the first line of the quote. Will not be {@code null}.
25+
*/
1226
public String getQuoteText() {
1327
String text = mQuoteText;
1428
if (text == null) {
@@ -17,6 +31,9 @@ public String getQuoteText() {
1731
return text;
1832
}
1933

34+
/**
35+
* Gets the second line of the quote. Will not be {@code null}.
36+
*/
2037
public String getQuoteSource() {
2138
String source = mQuoteSource;
2239
if (source == null) {

src/com/crossbowffs/quotelock/api/QuoteModule.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
import android.content.ComponentName;
44
import android.content.Context;
55

6+
/**
7+
* Provides an API for querying the information of a
8+
* quote provider and fetching quotes from that provider. Note that
9+
* all functions other than {@link QuoteModule#getQuote(Context)}
10+
* should return immediately, since they will be called on the
11+
* UI thread.
12+
*/
613
public interface QuoteModule {
714
/**
815
* Gets the user-friendly name of the quote provider that this module uses.
@@ -11,7 +18,8 @@ public interface QuoteModule {
1118
String getDisplayName(Context context);
1219

1320
/**
14-
* Gets the configuration {@link android.app.Activity} for this module.
21+
* Gets a {@link ComponentName} representing the configuration
22+
* {@link android.app.Activity} for this module.
1523
* Returns {@code null} if there is no configuration activity.
1624
*/
1725
ComponentName getConfigActivity(Context context);

src/com/crossbowffs/quotelock/app/CommonReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class CommonReceiver extends BroadcastReceiver {
1313
@Override
1414
public void onReceive(Context context, Intent intent) {
1515
String action = intent.getAction();
16-
Xlog.i(TAG, "Received action: %s", action);
16+
Xlog.d(TAG, "Received action: %s", action);
1717
if (Intent.ACTION_BOOT_COMPLETED.equals(action) || ConnectivityManager.CONNECTIVITY_ACTION.equals(action)) {
1818
JobUtils.createQuoteDownloadJob(context, false);
1919
}

src/com/crossbowffs/quotelock/app/QuoteDownloaderService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ protected void onCancelled(QuoteData quote) {
4444

4545
@Override
4646
public boolean onStartJob(JobParameters params) {
47-
Xlog.i(TAG, "Quote downloader job started");
47+
Xlog.d(TAG, "Quote downloader job started");
4848

4949
if (params.getJobId() != JobUtils.JOB_ID) {
5050
Xlog.e(TAG, "Job ID mismatch, ignoring");
5151
return false;
5252
}
5353

5454
if (!JobUtils.shouldRefreshQuote(this)) {
55-
Xlog.i(TAG, "Should not refresh quote now, ignoring");
55+
Xlog.d(TAG, "Should not refresh quote now, ignoring");
5656
return false;
5757
}
5858

src/com/crossbowffs/quotelock/app/QuoteDownloaderTask.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public QuoteDownloaderTask(Context context) {
2424

2525
@Override
2626
protected QuoteData doInBackground(Void... params) {
27-
Xlog.i(TAG, "Attempting to download new quote...");
27+
Xlog.d(TAG, "Attempting to download new quote...");
2828
QuoteModule module;
2929
try {
3030
module = ModuleManager.getModule(mContext, mModuleName);
3131
} catch (ModuleNotFoundException e) {
3232
Xlog.e(TAG, "Selected module not found", e);
3333
return null;
3434
}
35-
Xlog.i(TAG, "Provider: %s", module.getDisplayName(mContext));
35+
Xlog.d(TAG, "Provider: %s", module.getDisplayName(mContext));
3636
try {
3737
return module.getQuote(mContext);
3838
} catch (Exception e) {
@@ -45,8 +45,8 @@ protected QuoteData doInBackground(Void... params) {
4545
protected void onPostExecute(QuoteData quote) {
4646
Xlog.d(TAG, "QuoteDownloaderTask#onPostExecute called, success: %s", (quote != null));
4747
if (quote != null) {
48-
Xlog.i(TAG, "Text: %s", quote.getQuoteText());
49-
Xlog.i(TAG, "Source: %s", quote.getQuoteSource());
48+
Xlog.d(TAG, "Text: %s", quote.getQuoteText());
49+
Xlog.d(TAG, "Source: %s", quote.getQuoteSource());
5050
mContext.getSharedPreferences(PrefKeys.PREF_QUOTES, Context.MODE_PRIVATE)
5151
.edit()
5252
.putString(PrefKeys.PREF_QUOTES_TEXT, quote.getQuoteText())

0 commit comments

Comments
 (0)