Browse Source

UI overhaul

feature_fragments
vanitasvitae 5 years ago
parent
commit
2fa9e29e71
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
  1. 6
      app/src/main/AndroidManifest.xml
  2. 75
      app/src/main/java/de/trac/spherical/MainActivity.java
  3. 28
      app/src/main/res/layout/activity_main.xml
  4. 8
      app/src/main/res/menu/main_menu.xml
  5. 14
      app/src/main/res/values-v19/styles.xml
  6. 2
      app/src/main/res/values/strings.xml
  7. 24
      app/src/main/res/values/styles.xml

6
app/src/main/AndroidManifest.xml

@ -10,13 +10,13 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
>
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<!-- Launcher -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

75
app/src/main/java/de/trac/spherical/MainActivity.java

@ -3,11 +3,16 @@ package de.trac.spherical;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
@ -19,7 +24,6 @@ import java.io.InputStream;
import de.trac.spherical.parser.PhotoSphereMetadata;
import de.trac.spherical.parser.PhotoSphereParser;
import de.trac.spherical.rendering.Renderer;
import de.trac.spherical.rendering.SphereSurfaceView;
@ -33,35 +37,41 @@ public class MainActivity extends AppCompatActivity {
private SphereSurfaceView surfaceView;
private Renderer renderer;
private FloatingActionButton fab;
private Toolbar toolbar;
private AppBarLayout appBarLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize renderer and setup surface view.
surfaceView = new SphereSurfaceView(this);
renderer = new Renderer(surfaceView);
((LinearLayout) findViewById(R.id.container)).addView(surfaceView);
// Prepare UI
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
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.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
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.
final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent event) {
if (fab.isShown()) {
fab.setVisibility(View.INVISIBLE);
} else {
fab.show();
}
displayUI(!fab.isShown());
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
public void 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!");
}
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}
}

28
app/src/main/res/layout/activity_main.xml

@ -1,11 +1,37 @@
<?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:tools="http://schemas.android.com/tools"
android:id="@+id/lay_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false"
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
android:id="@+id/container"
android:orientation="vertical"

8
app/src/main/res/menu/main_menu.xml

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

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

2
app/src/main/res/values/strings.xml

@ -4,4 +4,6 @@
<string name="file_not_found">File not found.</string>
<string name="ioerror">An Error has occurred: IOError.</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>

24
app/src/main/res/values/styles.xml

@ -1,8 +1,22 @@
<resources>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
<!-- Application theme. -->
<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>
</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>

Loading…
Cancel
Save