Skip to content

Commit

Permalink
Project: Fix some problems & target sdk is up to 24
Browse files Browse the repository at this point in the history
Signed-off-by: Fung Go <[email protected]>
  • Loading branch information
fython committed Jun 18, 2016
1 parent fdf52c7 commit 5cdd589
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 29 deletions.
20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 24
buildToolsVersion "24.0.0"

defaultConfig {
applicationId "moe.feng.nhentai"
minSdkVersion 17
targetSdkVersion 23
versionCode 20
versionName "1.2.1"
targetSdkVersion 24
versionCode 21
versionName "1.2.1.1"
}
buildTypes {
release {
Expand All @@ -21,11 +21,11 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:support-v13:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.google.code.gson:gson:2.4'
compile 'org.jsoup:jsoup:1.8.2'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/java/moe/feng/nhentai/ui/BookDetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ protected void onCreate(Bundle savedInstanceState) {
TextDrawable textDrawable;
if (book.title != null) {
int color = ColorGenerator.MATERIAL.getColor(book.title);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mSets.getBoolean(Settings.KEY_ALLOW_STANDALONE_TASK, true)) {
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(
TextUtils.isEmpty(book.titleJP) ? book.title : book.titleJP,
null,
getResources().getColor(R.color.deep_purple_300)
getResources().getColor(R.color.deep_purple_500)
);
setTaskDescription(taskDesc);
}
Expand Down Expand Up @@ -273,7 +273,8 @@ private void setViewsTranslation(int target) {

public static void launch(Activity activity, ImageView imageView, Book book, int fromPosition) {
Intent intent = new Intent(activity, BookDetailsActivity.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& Settings.getInstance(activity).getBoolean(Settings.KEY_ALLOW_STANDALONE_TASK, true)) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
} else {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Expand Down Expand Up @@ -307,11 +308,11 @@ private void updateDetailsContent() {
mContentView.setVisibility(View.VISIBLE);
mContentView.animate().alphaBy(0f).alpha(1f).setDuration(1500).start();
mTitleText.setText(TextUtils.isEmpty(book.titleJP) ? book.title : book.titleJP);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mSets.getBoolean(Settings.KEY_ALLOW_STANDALONE_TASK, true)) {
ActivityManager.TaskDescription taskDesc = new ActivityManager.TaskDescription(
TextUtils.isEmpty(book.titleJP) ? book.title : book.titleJP,
null,
getResources().getColor(R.color.deep_purple_300)
getResources().getColor(R.color.deep_purple_500)
);
setTaskDescription(taskDesc);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package moe.feng.nhentai.ui.fragment.settings;

import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatSeekBar;
Expand All @@ -18,7 +19,7 @@
public class SettingsAppearance extends PreferenceFragment implements Preference.OnPreferenceClickListener, android.preference.Preference.OnPreferenceChangeListener {

private Preference mCardCountPref;
private SwitchPreference mHDImagePref, mFullHDPreviewPref;
private SwitchPreference mHDImagePref, mFullHDPreviewPref, mAllowStandaloneTaskPref;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -30,6 +31,12 @@ public void onCreate(Bundle savedInstanceState) {
mCardCountPref = (Preference) findPreference("card_count");
mHDImagePref = (SwitchPreference) findPreference("hd_image");
mFullHDPreviewPref = (SwitchPreference) findPreference("full_image_preview");
mAllowStandaloneTaskPref = (SwitchPreference) findPreference("allow_standalone_task");

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
mAllowStandaloneTaskPref.setEnabled(false);
mAllowStandaloneTaskPref.setSummary(R.string.set_title_android_too_old_desc);
}

int cardCount = mSets.getInt(Settings.KEY_CARDS_COUNT, -1);
mCardCountPref.setSummary(
Expand All @@ -42,10 +49,12 @@ public void onCreate(Bundle savedInstanceState) {
);
mHDImagePref.setChecked(mSets.getBoolean(Settings.KEY_LIST_HD_IMAGE, false));
mFullHDPreviewPref.setChecked(mSets.getBoolean(Settings.KEY_FULL_IMAGE_PREVIEW, false));
mAllowStandaloneTaskPref.setChecked(mSets.getBoolean(Settings.KEY_ALLOW_STANDALONE_TASK, true) && mAllowStandaloneTaskPref.isEnabled());

mCardCountPref.setOnPreferenceClickListener(this);
mHDImagePref.setOnPreferenceChangeListener(this);
mFullHDPreviewPref.setOnPreferenceChangeListener(this);
mAllowStandaloneTaskPref.setOnPreferenceChangeListener(this);
}

@Override
Expand Down Expand Up @@ -87,17 +96,17 @@ private void showCardCountCustomDialog() {
final AppCompatTextView numberText = (AppCompatTextView) view.findViewById(R.id.number_text);
final AppCompatSeekBar seekBar = (AppCompatSeekBar) view.findViewById(R.id.seekbar);
int cardCount = mSets.getInt(Settings.KEY_CARDS_COUNT, 2);
if (cardCount < 1) {
if (cardCount < 2) {
cardCount = 2;
}
numberText.setText(String.valueOf(cardCount));
seekBar.setKeyProgressIncrement(1);
seekBar.setMax(9);
seekBar.setProgress(cardCount - 1);
seekBar.setMax(8);
seekBar.setProgress(cardCount - 2);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
numberText.setText(String.valueOf(i + 1));
numberText.setText(String.valueOf(i + 2));
}

@Override
Expand All @@ -123,11 +132,11 @@ public void onClick(DialogInterface dialogInterface, int i) {
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
mSets.putInt(Settings.KEY_CARDS_COUNT, seekBar.getProgress() + 1);
mSets.putInt(Settings.KEY_CARDS_COUNT, seekBar.getProgress() + 2);
mCardCountPref.setSummary(
getString(
R.string.set_title_cards_count_summary,
String.valueOf(seekBar.getProgress() + 1)
String.valueOf(seekBar.getProgress() + 2)
)
);
showRestartTips();
Expand All @@ -151,6 +160,12 @@ public boolean onPreferenceChange(android.preference.Preference pref, Object o)
mFullHDPreviewPref.setChecked(b);
return true;
}
if (pref == mAllowStandaloneTaskPref) {
Boolean b = (Boolean) o;
mSets.putBoolean(Settings.KEY_ALLOW_STANDALONE_TASK, b);
mAllowStandaloneTaskPref.setChecked(b);
return true;
}
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/moe/feng/nhentai/util/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class Settings {

public static final String PREFERENCES_NAME = "settings";

public static final String KEY_CELEBRATE = "celebrate", KEY_CARDS_COUNT = "cards_count",
public static final String KEY_CELEBRATE = "celebrate", KEY_CARDS_COUNT = "cards_number",
KEY_LIST_HD_IMAGE = "list_hd_image", KEY_FULL_IMAGE_PREVIEW = "full_image_preview",
KEY_NO_MEDIA = "no_media_boolean";
KEY_NO_MEDIA = "no_media_boolean", KEY_ALLOW_STANDALONE_TASK = "allow_standalone_task";

private static Settings sInstance;

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/widget_search_box.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
android:padding="8dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:src="@drawable/abc_ic_menu_moreoverflow_mtrl_alpha"
android:visibility="gone"
android:src="@drawable/ic_photo_library_black_24dp"
android:scaleType="centerInside"
android:background="?attr/selectableItemBackgroundBorderless"/>

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<string name="category_details">信息页面</string>
<string name="set_title_full_image_in_details">加载全高清图片作预览图</string>
<string name="set_title_full_image_in_details_summary">这样会消耗大量流量和内存(壕任性选项)</string>
<string name="set_title_allow_standalone_task">允许任务独立</string>
<string name="set_title_allow_standalone_task_desc">每个本子都会显示为单独的任务</string>
<string name="set_title_android_too_old_desc">这个特性在你的 Android 版本上不被支持。</string>
<string name="settings_storage">存储</string>
<string name="category_folder">文件夹</string>
<string name="set_title_nomedia">在系统图库中隐藏已保存的本子</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<string name="category_details">資料頁面</string>
<string name="set_title_full_image_in_details">載入原圖作預覽圖像</string>
<string name="set_title_full_image_in_details_summary">這會消耗大量流量和內存(壕任性選項)</string>
<string name="set_title_allow_standalone_task">允許任務分離</string>
<string name="set_title_allow_standalone_task_desc">每個本子都會顯示為單獨的任務</string>
<string name="set_title_android_too_old_desc">這個特性在你的 Android 版本上不被支援。</string>
<string name="settings_storage">存儲</string>
<string name="category_folder">資料夾</string>
<string name="set_title_nomedia">在系統畫廊中隱藏已儲存的本子</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@
<string name="category_details">Info page</string>
<string name="set_title_full_image_in_details">Load Full HD images as preview</string>
<string name="set_title_full_image_in_details_summary">It will consume plenty of data usage and memory.</string>
<string name="set_title_allow_standalone_task">Allow standalone task</string>
<string name="set_title_allow_standalone_task_desc">Each book will be shown as a standalone task.</string>
<string name="set_title_android_too_old_desc">This feature isn\'t supported on your Android version</string>
<string name="settings_storage">Storage</string>
<string name="category_folder">Folder</string>
<string name="set_title_nomedia">Do not show saved books in gallery</string>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/xml/settings_ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
android:title="@string/set_title_full_image_in_details"
android:summary="@string/set_title_full_image_in_details_summary"/>

<moe.feng.nhentai.view.pref.SwitchPreference
android:key="allow_standalone_task"
android:title="@string/set_title_allow_standalone_task"
android:summary="@string/set_title_allow_standalone_task_desc"/>

</PreferenceCategory>

</PreferenceScreen>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha1'
classpath 'com.android.tools.build:gradle:2.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 3 additions & 3 deletions libraries/movingimageview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion 24
buildToolsVersion "24.0.0"

defaultConfig {
minSdkVersion 17
targetSdkVersion 23
targetSdkVersion 24
}
buildTypes {
release {
Expand Down

0 comments on commit 5cdd589

Please sign in to comment.