mirror of
https://github.com/vanitasvitae/Spherical
synced 2024-11-22 04:12:07 +01:00
UI overhaul
This commit is contained in:
parent
a6aa2b17f8
commit
2fa9e29e71
7 changed files with 134 additions and 23 deletions
|
@ -10,13 +10,13 @@
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
|
>
|
||||||
<activity android:name=".MainActivity"
|
<activity android:name=".MainActivity"
|
||||||
android:screenOrientation="portrait">
|
android:screenOrientation="portrait"
|
||||||
|
android:theme="@style/AppTheme">
|
||||||
<!-- Launcher -->
|
<!-- Launcher -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,16 @@ package de.trac.spherical;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.AppBarLayout;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.GestureDetector;
|
import android.view.GestureDetector;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
@ -19,7 +24,6 @@ import java.io.InputStream;
|
||||||
|
|
||||||
import de.trac.spherical.parser.PhotoSphereMetadata;
|
import de.trac.spherical.parser.PhotoSphereMetadata;
|
||||||
import de.trac.spherical.parser.PhotoSphereParser;
|
import de.trac.spherical.parser.PhotoSphereParser;
|
||||||
|
|
||||||
import de.trac.spherical.rendering.Renderer;
|
import de.trac.spherical.rendering.Renderer;
|
||||||
import de.trac.spherical.rendering.SphereSurfaceView;
|
import de.trac.spherical.rendering.SphereSurfaceView;
|
||||||
|
|
||||||
|
@ -33,35 +37,41 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private SphereSurfaceView surfaceView;
|
private SphereSurfaceView surfaceView;
|
||||||
private Renderer renderer;
|
private Renderer renderer;
|
||||||
private FloatingActionButton fab;
|
private FloatingActionButton fab;
|
||||||
|
private Toolbar toolbar;
|
||||||
|
private AppBarLayout appBarLayout;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
// Initialize renderer and setup surface view.
|
// Prepare UI
|
||||||
surfaceView = new SphereSurfaceView(this);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
renderer = new Renderer(surfaceView);
|
setSupportActionBar(toolbar);
|
||||||
((LinearLayout) findViewById(R.id.container)).addView(surfaceView);
|
appBarLayout = (AppBarLayout) findViewById(R.id.lay_toolbar);
|
||||||
|
AppBarLayout.LayoutParams lp = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
|
||||||
|
lp.topMargin += getStatusBarHeight();
|
||||||
|
appBarLayout.bringToFront();
|
||||||
fab = (FloatingActionButton) findViewById(R.id.fab);
|
fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
SphereSurfaceView.USE_TOUCH = !SphereSurfaceView.USE_TOUCH;
|
SphereSurfaceView.USE_TOUCH = !SphereSurfaceView.USE_TOUCH;
|
||||||
fab.setVisibility(View.INVISIBLE);
|
displayUI(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initialize renderer and setup surface view.
|
||||||
|
LinearLayout container = (LinearLayout) findViewById(R.id.container);
|
||||||
|
surfaceView = new SphereSurfaceView(this);
|
||||||
|
container.addView(surfaceView);
|
||||||
|
renderer = new Renderer(surfaceView);
|
||||||
|
|
||||||
// Detect gestures like single taps.
|
// Detect gestures like single taps.
|
||||||
final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
|
final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onSingleTapConfirmed(MotionEvent event) {
|
public boolean onSingleTapConfirmed(MotionEvent event) {
|
||||||
if (fab.isShown()) {
|
displayUI(!fab.isShown());
|
||||||
fab.setVisibility(View.INVISIBLE);
|
|
||||||
} else {
|
|
||||||
fab.show();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +98,38 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayUI(boolean display) {
|
||||||
|
if (display) {
|
||||||
|
fab.show();
|
||||||
|
appBarLayout.setExpanded(true, true);
|
||||||
|
} else {
|
||||||
|
fab.setVisibility(View.INVISIBLE);
|
||||||
|
appBarLayout.setExpanded(false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
fab.show();
|
displayUI(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.main_menu, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.menu_force_sphere:
|
||||||
|
Toast.makeText(this, R.string.not_yet_implemented, Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,4 +224,13 @@ public class MainActivity extends AppCompatActivity {
|
||||||
Log.d(TAG, "Display Flat Image!");
|
Log.d(TAG, "Display Flat Image!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getStatusBarHeight() {
|
||||||
|
int result = 0;
|
||||||
|
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||||
|
if (resourceId > 0) {
|
||||||
|
result = getResources().getDimensionPixelSize(resourceId);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,37 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/lay_root"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:fitsSystemWindows="false"
|
||||||
tools:context="de.trac.spherical.MainActivity">
|
tools:context="de.trac.spherical.MainActivity">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/lay_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="false"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
app:elevation="0dp">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="@android:color/transparent"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||||
|
app:theme="@style/AppTheme.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat" />
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|
8
app/src/main/res/menu/main_menu.xml
Normal file
8
app/src/main/res/menu/main_menu.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_force_sphere"
|
||||||
|
android:title="@string/menu_force_sphere"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
</menu>
|
14
app/src/main/res/values-v19/styles.xml
Normal file
14
app/src/main/res/values-v19/styles.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
|
<item name="android:windowTranslucentNavigation">true</item>
|
||||||
|
<item name="android:windowTranslucentStatus">true</item>
|
||||||
|
<item name="windowActionBarOverlay">false</item>
|
||||||
|
<item name="android:windowActionBarOverlay">false</item>
|
||||||
|
<item name="android:fitsSystemWindows">false</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
|
@ -4,4 +4,6 @@
|
||||||
<string name="file_not_found">File not found.</string>
|
<string name="file_not_found">File not found.</string>
|
||||||
<string name="ioerror">An Error has occurred: IOError.</string>
|
<string name="ioerror">An Error has occurred: IOError.</string>
|
||||||
<string name="wow">WOW! SUCH 3D!!!</string>
|
<string name="wow">WOW! SUCH 3D!!!</string>
|
||||||
|
<string name="menu_force_sphere">Show as Sphere</string>
|
||||||
|
<string name="not_yet_implemented">Not yet implemented!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
<resources>
|
<resources>
|
||||||
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
|
|
||||||
<item name="windowNoTitle">true</item>
|
<!-- Application theme. -->
|
||||||
<item name="windowActionBar">false</item>
|
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
<item name="android:windowFullscreen">true</item>
|
<item name="colorPrimary">@color/colorPrimary</item>
|
||||||
<item name="android:windowContentOverlay">@null</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- ACTION BAR STYLES -->
|
||||||
|
<style name="AppTheme.ActionBar" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||||
|
<item name="android:background">@android:color/transparent</item>
|
||||||
|
<item name="android:windowActionBarOverlay">true</item>
|
||||||
|
<item name="android:clipToPadding">false</item>
|
||||||
|
|
||||||
|
<!-- Support library compatibility -->
|
||||||
|
<item name="background">@android:color/transparent</item>
|
||||||
|
<item name="windowActionBarOverlay">true</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue