Commit 52a62c8e authored by Christof Wolke's avatar Christof Wolke

Ressources for SplashScreen

parent 7376ac0a
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintOrientation" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
package de.uni_oldenburg.bidl.base_view;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.estimote.sdk.Beacon;
import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;
import com.estimote.sdk.SystemRequirementsChecker;
import java.util.List;
import java.util.UUID;
import de.uni_oldenburg.bidl.R;
import pl.droidsonroids.gif.GifImageView;
import static de.uni_oldenburg.bidl.R.string.noBeaconFound;
public class SplashActivity extends AppCompatActivity {
/** Estimote Beacon UUID **/
private static final UUID PROXIMITY_UUID = UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D");
/** Tag for Logging **/
private static final String TAG = SplashActivity.class.getSimpleName();
/** GUI **/
private ImageView uniLogo;
private GifImageView loadingSpinner;
private TextView splashMessage;
/** Values **/
private Region region;
private BeaconManager beaconManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
/** init **/
uniLogo = (ImageView) findViewById(R.id.uniLogo);
loadingSpinner = (GifImageView) findViewById(R.id.loadingSpinner);
splashMessage = (TextView) findViewById(R.id.splashText);
/** Fullscreen modus **/
getWindow().getDecorView().setSystemUiVisibility(
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);
/**
* Start ranging for beacons.
**/
beaconManager = new BeaconManager(this);
beaconManager.setForegroundScanPeriod(7000,5000);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
if (!list.isEmpty()){
Beacon nearestBeacon = list.get(0);
toMainActivity();
// TODO: 30.07.2016 save the Beacon in the database and overwrite the DB, when the nearestBeacon != the saved beacon.
} if (list.isEmpty()){
// TODO: 30.07.2016 toScrenn beacon not found...
showMessage();
}
}
});
region = new Region("ranged region", PROXIMITY_UUID, null, null);
//// TODO: 29.07.2016 Servercall to get the Event, which takes place, get the Beacon from the Database.
// TODO: 30.07.2016 React, when the user is nearer to another Beacon.
}
@Override
protected void onResume(){
super.onResume();
// is Bluetooth on, is Location on, etc.
SystemRequirementsChecker.checkWithDefaultDialogs(this);
// Start ranging for beacons, when the activity appears on the screen
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startRanging(region);
}
});
}
/**
* Ranging ist stopped, if the Activity disappears.
*/
@Override
public void onPause(){
beaconManager.stopRanging(region);
super.onPause();
}
private void toMainActivity() {
startActivity(new Intent(this, MainActivity.class));
}
private void showMessage() {
Toast.makeText(this, noBeaconFound, Toast.LENGTH_SHORT).show();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="de.uni_oldenburg.bidl.base_view.SplashActivity"
android:orientation="vertical"
android:background="@color/white">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/unilogo"
android:layout_marginTop="70dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:id="@+id/uniLogo"
android:contentDescription="@string/imageViewDescription"
android:clickable="false"/>
<pl.droidsonroids.gif.GifImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/loadingspinner"
android:id="@+id/loadingSpinner"
android:layout_gravity="center"
android:layout_marginTop="120dp"
android:contentDescription="@string/gifImageViewDescription"
android:clickable="false"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/splashText"
android:text="@string/splashMessage"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:fontFamily="sans-serif"
android:textSize="18sp"
android:textStyle="normal|italic" />
</LinearLayout>
<resources>
<!-- Declare custom theme attributes that allow changing which styles are
used for button bars depending on the API level.
?android:attr/buttonBarStyle is new as of API 11 so this is
necessary to support previous API levels. -->
<declare-styleable name="ButtonBarContainerTheme">
<attr name="metaButtonBarStyle" format="reference" />
<attr name="metaButtonBarButtonStyle" format="reference" />
</declare-styleable>
</resources>
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