UI improvements.

parent 7c388902
......@@ -2,7 +2,9 @@ package com.systemallica.gallery;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;
......@@ -28,6 +30,12 @@ public class AboutActivity extends AppCompatActivity {
//Add version number to the TextView
String version = getResources().getString(R.string.about_name) + " " + BuildConfig.VERSION_NAME;
app_name.setText(version);
// Change navBar colour
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int app_primary = ContextCompat.getColor(this, R.color.app_primary);
getWindow().setNavigationBarColor(app_primary);
}
}
//Send email
......
......@@ -3,8 +3,10 @@ package com.systemallica.gallery;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
......@@ -47,6 +49,12 @@ public class FolderActivity extends AppCompatActivity {
// Display arrow to return to previous activity
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// Change navBar colour
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int app_primary = ContextCompat.getColor(this, R.color.app_primary);
getWindow().setNavigationBarColor(app_primary);
}
}
@Override
......@@ -178,7 +186,7 @@ public class FolderActivity extends AppCompatActivity {
Intent intent = new Intent(FolderActivity.this, VideoActivity.class);
// Pass arrayList of image paths
intent.putExtra("position", position);
intent.putExtra("list_of_images", list_of_paths);
intent.putExtra("videoPath", list_of_paths.get(position));
// Start activity
startActivityForResult(intent, 2);
}else {
......
......@@ -5,14 +5,17 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
......@@ -59,7 +62,7 @@ public class ImageActivity extends AppCompatActivity {
private final Runnable mShowRunnable = new Runnable() {
@Override
public void run() {
// Delayed display of UI elements
// Display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
......@@ -119,6 +122,12 @@ public class ImageActivity extends AppCompatActivity {
getSupportActionBar().setTitle(new File(list_of_images.get(position_intent)).getName());
}
// Make navBar translucent
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int translucentBackground = ContextCompat.getColor(this, R.color.translucent_background);
getWindow().setNavigationBarColor(translucentBackground);
}
// Set result to 0 -> No file deleted
setResult(0);
......@@ -153,7 +162,6 @@ public class ImageActivity extends AppCompatActivity {
mHideHandler.post(mHideRunnable);
}
@SuppressLint("InlinedApi")
private void show() {
// Show the system bar
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
......@@ -195,10 +203,10 @@ public class ImageActivity extends AppCompatActivity {
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
public Object instantiateItem(ViewGroup container, final int position) {
File image = new File(list_of_images.get(position));
final File image = new File(list_of_images.get(position));
// Inflate layout
LayoutInflater inflater = getLayoutInflater();
......@@ -216,16 +224,48 @@ public class ImageActivity extends AppCompatActivity {
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into(imageView);
if(Utils.isVideo(image.getName())) {
SubsamplingScaleImageView subSampling = layout.findViewById(R.id.inside_imageview_sub);
// Add overlay
overlay.setVisibility(View.VISIBLE);
// Play video on tap
overlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.e("click", "glide");
// Create video intent
Intent intent = new Intent(ImageActivity.this, VideoActivity.class);
// Pass arrayList of image paths
intent.putExtra("position", position);
intent.putExtra("videoPath", image.getAbsolutePath());
// Start activity
startActivityForResult(intent, 2);
}
});
// Set up the user interaction to manually show or hide the system UI.
subSampling.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
toggle();
}
});
imageView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
toggle();
}
});
}else {
// Set up the user interaction to manually show or hide the system UI.
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
}
// Set up the user interaction to manually show or hide the system UI.
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
// Full image display
}else{
// Get subSampling view
......
......@@ -8,10 +8,10 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
......@@ -80,6 +80,12 @@ public class MainActivity extends AppCompatActivity {
startRefresh();
}
});
// Change navBar colour
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int app_primary = ContextCompat.getColor(this, R.color.app_primary);
getWindow().setNavigationBarColor(app_primary);
}
}
@Override
......@@ -401,5 +407,4 @@ public class MainActivity extends AppCompatActivity {
});
}
}
package com.systemallica.gallery;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
......@@ -35,7 +36,6 @@ import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Formatter;
import java.util.GregorianCalendar;
......@@ -43,25 +43,24 @@ import java.util.Locale;
public class VideoActivity extends AppCompatActivity {
private static final int UI_ANIMATION_DELAY = 300;
private final Handler mHideHandler = new Handler();
private final Runnable mHidePart2Runnable = new Runnable() {
@SuppressLint("InlinedApi")
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
};
private final Runnable mShowPart2Runnable = new Runnable() {
private final Runnable mShowRunnable = new Runnable() {
@Override
public void run() {
// Delayed display of UI elements
// Display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
......@@ -69,15 +68,10 @@ public class VideoActivity extends AppCompatActivity {
}
};
private boolean mVisible;
private final Runnable mHideRunnable = new Runnable() {
@Override
public void run() {
hide();
}
};
private SimpleExoPlayerView playerView;
private SimpleExoPlayer player;
ArrayList<String> list_of_videos = new ArrayList<>();
String videoPath;
int position_intent;
@Override
......@@ -94,7 +88,7 @@ public class VideoActivity extends AppCompatActivity {
Intent intent = getIntent();
// Get all the images in the folder
list_of_videos = intent.getStringArrayListExtra("list_of_images");
videoPath = intent.getStringExtra("videoPath");
// Get position
position_intent = intent.getIntExtra("position", 0);
......@@ -102,7 +96,13 @@ public class VideoActivity extends AppCompatActivity {
// Display arrow to return to previous activity
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Set current title
getSupportActionBar().setTitle(new File(list_of_videos.get(position_intent)).getName());
getSupportActionBar().setTitle(new File(videoPath).getName());
}
// Make navBar translucent
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
int translucentBackground = ContextCompat.getColor(this, R.color.translucent_background);
getWindow().setNavigationBarColor(translucentBackground);
}
exoPlayer();
......@@ -147,7 +147,7 @@ public class VideoActivity extends AppCompatActivity {
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide();
hide();
}
@Override
......@@ -160,7 +160,7 @@ public class VideoActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
File file = new File(list_of_videos.get(position_intent));
File file = new File(videoPath);
switch(id){
case R.id.action_share:
shareVideo(file);
......@@ -277,7 +277,7 @@ public class VideoActivity extends AppCompatActivity {
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
// This is the MediaSource representing the media to be played.
MediaSource videoSource = new ExtractorMediaSource(Uri.fromFile(new File(list_of_videos.get(position_intent))),
MediaSource videoSource = new ExtractorMediaSource(Uri.fromFile(new File(videoPath)),
dataSourceFactory, extractorsFactory, null, null);
// Prepare the player with the source.
......@@ -303,11 +303,10 @@ public class VideoActivity extends AppCompatActivity {
mVisible = false;
// Schedule a runnable to remove the status and navigation bar
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.post(mHidePart2Runnable);
mHideHandler.removeCallbacks(mShowRunnable);
mHideHandler.post(mHideRunnable);
}
@SuppressLint("InlinedApi")
private void show() {
playerView.showController();
// Show the system bar
......@@ -316,12 +315,8 @@ public class VideoActivity extends AppCompatActivity {
mVisible = true;
// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}
private void delayedHide() {
mHideHandler.removeCallbacks(mHideRunnable);
mHideHandler.postDelayed(mHideRunnable, UI_ANIMATION_DELAY);
mHideHandler.post(mShowRunnable);
}
}
......@@ -13,7 +13,6 @@
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
......
......@@ -13,7 +13,6 @@
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
......
......@@ -14,7 +14,6 @@
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
......
......@@ -6,24 +6,18 @@
android:layout_height="match_parent"
tools:context="com.systemallica.gallery.VideoActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_marginTop="24dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/translucent_background"
app:theme="@style/ToolBarStyle"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.CoordinatorLayout>
......@@ -11,6 +11,7 @@
<GridView
android:id="@+id/gridView"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:id="@+id/relativeLayout"
android:clickable="true"
android:focusable="true">
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
android:id="@+id/inside_imageview_sub"
......@@ -9,8 +12,9 @@
<ImageView
android:id="@+id/inside_imageview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:contentDescription="@string/desc_full_image"/>
<ImageView
......
......@@ -7,7 +7,6 @@
<item name="colorPrimaryDark">@color/app_primary_dark</item>
<item name="colorAccent">@color/app_color_accent</item>
<item name="android:windowBackground">@color/app_background</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="AppTheme.NoActionBar">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment