diff options
author | Andrew Dolgov <[email protected]> | 2014-10-16 15:36:58 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2014-10-16 15:36:58 +0400 |
commit | cc3d05e613b9b328621269ddf5d1895701ba9e13 (patch) | |
tree | 0481295eda249dd16f042af6607935515b46ca22 /src | |
parent | 8feb30db5acfd3c6ad5e6615f015dfb4929f1881 (diff) |
add kitkat statusbar tinting
add swipetoreload
Diffstat (limited to 'src')
-rw-r--r-- | src/org/fox/ttcomics/ComicListFragment.java | 23 | ||||
-rw-r--r-- | src/org/fox/ttcomics/CommonActivity.java | 18 | ||||
-rw-r--r-- | src/org/fox/ttcomics/MainActivity.java | 2 | ||||
-rw-r--r-- | src/org/fox/ttcomics/ViewComicActivity.java | 7 |
4 files changed, 48 insertions, 2 deletions
diff --git a/src/org/fox/ttcomics/ComicListFragment.java b/src/org/fox/ttcomics/ComicListFragment.java index 31dbf19..26166fc 100644 --- a/src/org/fox/ttcomics/ComicListFragment.java +++ b/src/org/fox/ttcomics/ComicListFragment.java @@ -18,6 +18,7 @@ import android.preference.PreferenceManager; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SimpleCursorAdapter;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextMenu;
@@ -53,6 +54,7 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { private ComicsListAdapter m_adapter;
private int m_mode = 0;
private String m_baseDirectory = "";
+ private SwipeRefreshLayout m_swipeLayout;
public ComicListFragment() {
super();
@@ -238,6 +240,22 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { //m_files = savedInstanceState.getStringArrayList("files");
}
+ m_swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.comics_swipe_container);
+
+ m_swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ rescan(true);
+ }
+ });
+
+ if (!CommonActivity.isCompatMode()) {
+ m_swipeLayout.setColorScheme(android.R.color.holo_green_dark,
+ android.R.color.holo_red_dark,
+ android.R.color.holo_blue_dark,
+ android.R.color.holo_orange_dark);
+ }
+
m_adapter = new ComicsListAdapter(getActivity(), R.layout.comics_list_row, createCursor(),
new String[] { "filename" }, new int[] { R.id.file_name }, 0);
@@ -351,7 +369,8 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { }
protected void rescan(final boolean fullRescan) {
-
+ m_swipeLayout.setRefreshing(true);
+
AsyncTask<String, Integer, Integer> rescanTask = new AsyncTask<String, Integer, Integer>() {
@Override
@@ -448,6 +467,8 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { if (isAdded() && m_activity != null) {
m_activity.cleanupCache(false);
m_activity.cleanupSqliteCache(comicsDir);
+
+ m_swipeLayout.setRefreshing(false);
}
return fileIndex; //m_files.size();
diff --git a/src/org/fox/ttcomics/CommonActivity.java b/src/org/fox/ttcomics/CommonActivity.java index ef3cdc4..6d392d2 100644 --- a/src/org/fox/ttcomics/CommonActivity.java +++ b/src/org/fox/ttcomics/CommonActivity.java @@ -6,6 +6,8 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException;
import java.util.Date;
+import com.readystatesoftware.systembartint.SystemBarTintManager;
+
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlertDialog;
@@ -26,6 +28,7 @@ import android.preference.PreferenceManager; import android.provider.BaseColumns;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Display;
import android.view.MenuItem;
import android.view.View;
@@ -597,6 +600,21 @@ public class CommonActivity extends ActionBarActivity { }
}
}
+
+ public void setStatusBarTint() {
+ if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.KITKAT) {
+ SystemBarTintManager tintManager = new SystemBarTintManager(this);
+ // enable status bar tint
+ tintManager.setStatusBarTintEnabled(true);
+ // enable navigation bar tint
+ tintManager.setNavigationBarTintEnabled(true);
+
+ TypedValue tv = new TypedValue();
+ getTheme().resolveAttribute(R.attr.statusBarHintColor, tv, true);
+
+ tintManager.setStatusBarTintColor(tv.data);
+ }
+ }
public void hideSystemUiIfNecessary() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
diff --git a/src/org/fox/ttcomics/MainActivity.java b/src/org/fox/ttcomics/MainActivity.java index cf2f798..0e589fa 100644 --- a/src/org/fox/ttcomics/MainActivity.java +++ b/src/org/fox/ttcomics/MainActivity.java @@ -13,6 +13,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; +import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar.Tab; import android.util.Log; @@ -76,6 +77,7 @@ public class MainActivity extends CommonActivity { setProgressBarVisibility(false); + setStatusBarTint(); setSmallScreen(findViewById(R.id.tablet_layout_hack) == null); if (savedInstanceState == null) { diff --git a/src/org/fox/ttcomics/ViewComicActivity.java b/src/org/fox/ttcomics/ViewComicActivity.java index deda68c..4459e18 100644 --- a/src/org/fox/ttcomics/ViewComicActivity.java +++ b/src/org/fox/ttcomics/ViewComicActivity.java @@ -42,13 +42,18 @@ public class ViewComicActivity extends CommonActivity { super.onCreate(savedInstanceState);
if (!isCompatMode())
- setTheme(m_prefs.getBoolean("use_dark_theme", false) ? R.style.DarkTheme : R.style.AppTheme);
+ setTheme(m_prefs.getBoolean("use_dark_theme", false) ? R.style.ViewDarkTheme : R.style.ViewLightTheme);
requestWindowFeature(Window.FEATURE_PROGRESS);
if (m_prefs.getBoolean("prevent_screen_sleep", false))
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.KITKAT && !m_prefs.getBoolean("use_full_screen", false)) {
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ setStatusBarTint();
+ }
+
setContentView(R.layout.activity_view_comic);
if (savedInstanceState == null) {
|