Icons in main tabs, improved video activity a bit

This commit is contained in:
Eugen Rochko 2017-03-12 13:41:29 +01:00
parent b3b3f2a88d
commit f508e8bc34
10 changed files with 85 additions and 12 deletions

View File

@ -37,7 +37,7 @@
<activity
android:name=".ComposeActivity"
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity android:name=".ViewVideoActivity" />
<activity android:name=".ViewVideoActivity" android:configChanges="orientation|keyboardHidden|screenSize" />
<activity android:name=".ViewThreadActivity" />
<activity android:name=".ViewTagActivity" />
<activity android:name=".AccountActivity" />

View File

@ -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)

View File

@ -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();

View File

@ -55,6 +55,6 @@ class TimelinePagerAdapter extends FragmentPagerAdapter {
@Override
public CharSequence getPageTitle(int position) {
return pageTitles[position];
return null;
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/toolbar_icon_dark"
android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z"/>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/toolbar_icon_dark"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z"/>
</vector>

View File

@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="@color/toolbar_icon_dark"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM11,19.93c-3.95,-0.49 -7,-3.85 -7,-7.93 0,-0.62 0.08,-1.21 0.21,-1.79L9,15v1c0,1.1 0.9,2 2,2v1.93zM17.9,17.39c-0.26,-0.81 -1,-1.39 -1.9,-1.39h-1v-3c0,-0.55 -0.45,-1 -1,-1L8,12v-2h2c0.55,0 1,-0.45 1,-1L11,7h2c1.1,0 2,-0.9 2,-2v-0.41c2.93,1.19 5,4.06 5,7.41 0,2.08 -0.8,3.97 -2.1,5.39z"/>
</vector>

View File

@ -25,14 +25,12 @@
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<FrameLayout
android:id="@+id/overlay_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>

View File

@ -1,14 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/view_video_background">
android:background="@color/view_video_background"
tools:context=".ViewVideoActivity">
<VideoView
android:id="@+id/video_player"
android:layout_marginTop="?attr/actionBarSize"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/AppTheme.Account.AppBarLayout"
app:popupTheme="@style/AppTheme.Account.ToolbarPopupTheme.Dark"
android:elevation="4dp"
android:background="@color/semi_transparent" />
</android.support.design.widget.CoordinatorLayout>