From f508e8bc34cbedb06fc0f6e1f75ba6acc7247f97 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 12 Mar 2017 13:41:29 +0100 Subject: [PATCH] Icons in main tabs, improved video activity a bit --- app/src/main/AndroidManifest.xml | 2 +- .../com/keylesspalace/tusky/MainActivity.java | 18 +++++++++- .../com/keylesspalace/tusky/SFragment.java | 1 - .../tusky/TimelinePagerAdapter.java | 2 +- .../tusky/ViewVideoActivity.java | 36 +++++++++++++++++-- app/src/main/res/drawable/ic_home_24dp.xml | 9 +++++ .../res/drawable/ic_notifications_24dp.xml | 9 +++++ app/src/main/res/drawable/ic_public_24dp.xml | 2 +- .../main/res/layout/activity_view_thread.xml | 2 -- .../main/res/layout/activity_view_video.xml | 16 +++++++-- 10 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable/ic_home_24dp.xml create mode 100644 app/src/main/res/drawable/ic_notifications_24dp.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fae43e26..84193826 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index ff984ee3..cb1504ef 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -20,6 +20,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -27,6 +28,7 @@ import android.os.SystemClock; import android.preference.PreferenceManager; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.TabLayout; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.os.Bundle; import android.support.v7.widget.Toolbar; @@ -121,6 +123,10 @@ public class MainActivity extends BaseActivity { tabLayout.setupWithViewPager(viewPager); + tabLayout.getTabAt(0).setIcon(R.drawable.ic_home_24dp); + tabLayout.getTabAt(1).setIcon(R.drawable.ic_notifications_24dp); + tabLayout.getTabAt(2).setIcon(R.drawable.ic_public_24dp); + tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { @@ -135,11 +141,12 @@ public class MainActivity extends BaseActivity { } pageHistory.push(tab.getPosition()); + tintTab(tab, true); } @Override public void onTabUnselected(TabLayout.Tab tab) { - + tintTab(tab, false); } @Override @@ -155,7 +162,12 @@ public class MainActivity extends BaseActivity { if (tabPosition != 0) { tabLayout.getTabAt(tabPosition).select(); + tintTab(tabLayout.getTabAt(tabPosition), true); + } else { + tintTab(tabLayout.getTabAt(0), true); } + } else { + tintTab(tabLayout.getTabAt(0), true); } // Setup push notifications @@ -172,6 +184,10 @@ public class MainActivity extends BaseActivity { }); } + private void tintTab(TabLayout.Tab tab, boolean tinted) { + tab.getIcon().setColorFilter(ContextCompat.getColor(this, tinted ? R.color.color_accent_dark : R.color.toolbar_icon_dark), PorterDuff.Mode.SRC_IN); + } + private void setupDrawer() { headerResult = new AccountHeaderBuilder() .withActivity(this) diff --git a/app/src/main/java/com/keylesspalace/tusky/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/SFragment.java index d1de088e..862e598c 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/SFragment.java @@ -206,7 +206,6 @@ public class SFragment extends Fragment { FragmentManager manager = getFragmentManager(); manager.beginTransaction() - .setCustomAnimations(R.anim.zoom_in, R.anim.zoom_out, R.anim.zoom_in, R.anim.zoom_out) .add(R.id.overlay_fragment_container, newFragment) .addToBackStack(null) .commit(); diff --git a/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java b/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java index 7cf0642d..883d56ea 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/TimelinePagerAdapter.java @@ -55,6 +55,6 @@ class TimelinePagerAdapter extends FragmentPagerAdapter { @Override public CharSequence getPageTitle(int position) { - return pageTitles[position]; + return null; } } diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java b/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java index 4fd83070..1ec2fa71 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ViewVideoActivity.java @@ -16,21 +16,53 @@ package com.keylesspalace.tusky; import android.os.Bundle; +import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; import android.widget.MediaController; import android.widget.VideoView; -public class ViewVideoActivity extends AppCompatActivity { +import butterknife.BindView; +import butterknife.ButterKnife; + +public class ViewVideoActivity extends BaseActivity { + @BindView(R.id.video_player) VideoView videoView; + @BindView(R.id.toolbar) Toolbar toolbar; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_video); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + + ActionBar bar = getSupportActionBar(); + + if (bar != null) { + bar.setTitle(null); + bar.setDisplayHomeAsUpEnabled(true); + bar.setDisplayShowHomeEnabled(true); + } + String url = getIntent().getStringExtra("url"); - VideoView videoView = (VideoView) findViewById(R.id.video_player); + videoView.setVideoPath(url); MediaController controller = new MediaController(this); videoView.setMediaController(controller); controller.show(); videoView.start(); } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: { + onBackPressed(); + return true; + } + } + return super.onOptionsItemSelected(item); + } } diff --git a/app/src/main/res/drawable/ic_home_24dp.xml b/app/src/main/res/drawable/ic_home_24dp.xml new file mode 100644 index 00000000..55e6239b --- /dev/null +++ b/app/src/main/res/drawable/ic_home_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_notifications_24dp.xml b/app/src/main/res/drawable/ic_notifications_24dp.xml new file mode 100644 index 00000000..86ed9486 --- /dev/null +++ b/app/src/main/res/drawable/ic_notifications_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_public_24dp.xml b/app/src/main/res/drawable/ic_public_24dp.xml index d976b424..f66427b1 100644 --- a/app/src/main/res/drawable/ic_public_24dp.xml +++ b/app/src/main/res/drawable/ic_public_24dp.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/layout/activity_view_thread.xml b/app/src/main/res/layout/activity_view_thread.xml index d808ea49..e714bf43 100644 --- a/app/src/main/res/layout/activity_view_thread.xml +++ b/app/src/main/res/layout/activity_view_thread.xml @@ -25,14 +25,12 @@ android:id="@+id/fragment_container" android:layout_width="match_parent" android:layout_height="match_parent" /> - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_view_video.xml b/app/src/main/res/layout/activity_view_video.xml index 77001cba..38e3cfab 100644 --- a/app/src/main/res/layout/activity_view_video.xml +++ b/app/src/main/res/layout/activity_view_video.xml @@ -1,14 +1,24 @@ - + android:background="@color/view_video_background" + tools:context=".ViewVideoActivity"> - + \ No newline at end of file