Done Items anzeigen, Push fix
Done Items können angezeigt werden Push kann empfangen werden
This commit is contained in:
		@@ -12,9 +12,10 @@
 | 
			
		||||
        android:supportsRtl="true"
 | 
			
		||||
        android:theme="@style/AppTheme"
 | 
			
		||||
        android:usesCleartextTraffic="true">
 | 
			
		||||
        <activity android:name=".activitys.DoneItemActivity"></activity>
 | 
			
		||||
        <activity
 | 
			
		||||
            android:name=".activitys.ItemListActivity"
 | 
			
		||||
            android:label="@string/title_activity_item_list"></activity>
 | 
			
		||||
            android:label="@string/title_activity_item_list" />
 | 
			
		||||
        <activity android:name=".activitys.Colorpicker" />
 | 
			
		||||
        <activity android:name=".activitys.LoginActivity">
 | 
			
		||||
            <intent-filter>
 | 
			
		||||
@@ -41,7 +42,9 @@
 | 
			
		||||
        <meta-data
 | 
			
		||||
            android:name="com.google.firebase.messaging.default_notification_color"
 | 
			
		||||
            android:resource="@color/colorAccent" /> <!-- [START firebase_service] -->
 | 
			
		||||
        <service android:name=".messaging.MyFirebaseMessagingService">
 | 
			
		||||
        <service
 | 
			
		||||
            android:name=".messaging.MyFirebaseMessagingService"
 | 
			
		||||
            android:stopWithTask="false">
 | 
			
		||||
            <intent-filter>
 | 
			
		||||
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,7 @@ import android.net.Uri;
 | 
			
		||||
import android.os.Build;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.Handler;
 | 
			
		||||
import android.support.annotation.NonNull;
 | 
			
		||||
import android.support.design.widget.FloatingActionButton;
 | 
			
		||||
import android.support.design.widget.Snackbar;
 | 
			
		||||
import android.support.design.widget.TabLayout;
 | 
			
		||||
@@ -34,8 +35,12 @@ import android.widget.TabHost;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import com.google.android.gms.tasks.OnCompleteListener;
 | 
			
		||||
import com.google.android.gms.tasks.Task;
 | 
			
		||||
import com.google.firebase.auth.FirebaseAuth;
 | 
			
		||||
import com.google.firebase.auth.FirebaseUser;
 | 
			
		||||
import com.google.firebase.iid.FirebaseInstanceId;
 | 
			
		||||
import com.google.firebase.iid.InstanceIdResult;
 | 
			
		||||
import com.google.gson.JsonSerializer;
 | 
			
		||||
import com.squareup.picasso.Picasso;
 | 
			
		||||
 | 
			
		||||
@@ -85,6 +90,40 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Holt den msg token
 | 
			
		||||
     *
 | 
			
		||||
     * SETZT IHN NOCH NED
 | 
			
		||||
     *
 | 
			
		||||
     *
 | 
			
		||||
     * WEITER PROGRAMMIERN
 | 
			
		||||
     *
 | 
			
		||||
     * MIR FEHLT NOCH DIE DB VON LUKAS
 | 
			
		||||
     */
 | 
			
		||||
    private void setMsgId(){
 | 
			
		||||
        FirebaseInstanceId.getInstance().getInstanceId()
 | 
			
		||||
                .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void onComplete(@NonNull Task<InstanceIdResult> task) {
 | 
			
		||||
                        if (!task.isSuccessful()) {
 | 
			
		||||
                            Log.w("SmartShopper", "getInstanceId failed", task.getException());
 | 
			
		||||
                            return;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        // Get new Instance ID token
 | 
			
		||||
                        String token = task.getResult().getToken();
 | 
			
		||||
                        Log.d("SmartShopper MSG", token);
 | 
			
		||||
 | 
			
		||||
                        /* Log and toast
 | 
			
		||||
                        String msg = getString(R.string.msg_token_fmt, token);
 | 
			
		||||
                        Log.d(TAG, msg);
 | 
			
		||||
                        Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
 | 
			
		||||
 | 
			
		||||
                        */
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convertiert eine int farbe in eine hexa dezimale Farbe
 | 
			
		||||
     *
 | 
			
		||||
@@ -103,6 +142,7 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
			
		||||
        color = "ffffff";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        setMsgId();
 | 
			
		||||
        // Erstellt die Tabs
 | 
			
		||||
        tabHoster();
 | 
			
		||||
 | 
			
		||||
@@ -429,6 +469,10 @@ public class Dash extends AppCompatActivity implements ShoppinglistAdapter.OnIte
 | 
			
		||||
            case R.id.addInvite:
 | 
			
		||||
                popupaddInvite();
 | 
			
		||||
 | 
			
		||||
            case R.id.doneEinkauf:
 | 
			
		||||
                Intent intent = new Intent(Dash.this, DoneItemActivity.class);
 | 
			
		||||
                startActivity(intent);
 | 
			
		||||
 | 
			
		||||
            default:
 | 
			
		||||
                // If we got here, the user's action was not recognized.
 | 
			
		||||
                // Invoke the superclass to handle it.
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,74 @@
 | 
			
		||||
package at.smartshopper.smartshopper.activitys;
 | 
			
		||||
 | 
			
		||||
import android.support.v4.widget.SwipeRefreshLayout;
 | 
			
		||||
import android.support.v7.app.AppCompatActivity;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.support.v7.widget.LinearLayoutManager;
 | 
			
		||||
import android.support.v7.widget.RecyclerView;
 | 
			
		||||
 | 
			
		||||
import org.json.JSONException;
 | 
			
		||||
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import at.smartshopper.smartshopper.R;
 | 
			
		||||
import at.smartshopper.smartshopper.customViews.SpaceItemDecoration;
 | 
			
		||||
import at.smartshopper.smartshopper.db.Database;
 | 
			
		||||
import at.smartshopper.smartshopper.shoppinglist.Shoppinglist;
 | 
			
		||||
import at.smartshopper.smartshopper.shoppinglist.ShoppinglistSharedAdapter;
 | 
			
		||||
import at.smartshopper.smartshopper.shoppinglist.details.item.Item;
 | 
			
		||||
import at.smartshopper.smartshopper.shoppinglist.details.item.ItemShoppinglistDetailsAdapter;
 | 
			
		||||
 | 
			
		||||
public class DoneItemActivity extends AppCompatActivity {
 | 
			
		||||
 | 
			
		||||
    private Database db;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        setContentView(R.layout.activity_done_item);
 | 
			
		||||
 | 
			
		||||
        db = new Database();
 | 
			
		||||
 | 
			
		||||
        final SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.doneItemListRefresh);
 | 
			
		||||
 | 
			
		||||
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onRefresh() {
 | 
			
		||||
                swipeRefreshLayout.setRefreshing(true);
 | 
			
		||||
                try {
 | 
			
		||||
                    showDoneItems();
 | 
			
		||||
                } catch (SQLException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                } catch (JSONException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                }
 | 
			
		||||
                swipeRefreshLayout.setRefreshing(false);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            showDoneItems();
 | 
			
		||||
        } catch (SQLException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        } catch (JSONException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Zeigt alle erledigten Items an
 | 
			
		||||
     * @throws SQLException
 | 
			
		||||
     * @throws JSONException
 | 
			
		||||
     */
 | 
			
		||||
    private void showDoneItems() throws SQLException, JSONException {
 | 
			
		||||
        RecyclerView doneRecycle = (RecyclerView) findViewById(R.id.doneitemsrecycle);
 | 
			
		||||
        doneRecycle.setHasFixedSize(true);
 | 
			
		||||
        int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.item_spacing);
 | 
			
		||||
        doneRecycle.addItemDecoration(new SpaceItemDecoration(spacingInPixels));
 | 
			
		||||
        doneRecycle.setLayoutManager(new LinearLayoutManager(this));
 | 
			
		||||
        List<Item> doneItems = db.getDoneItems();
 | 
			
		||||
        ItemShoppinglistDetailsAdapter islAdapter = new ItemShoppinglistDetailsAdapter(doneItems);
 | 
			
		||||
        doneRecycle.setAdapter(islAdapter);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -24,49 +24,10 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
 | 
			
		||||
     *
 | 
			
		||||
     * @param remoteMessage Object representing the message received from Firebase Cloud Messaging.
 | 
			
		||||
     */
 | 
			
		||||
    // [START receive_message]
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onMessageReceived(RemoteMessage remoteMessage) {
 | 
			
		||||
        // [START_EXCLUDE]
 | 
			
		||||
        // There are two types of messages data messages and notification messages. Data messages
 | 
			
		||||
        // are handled
 | 
			
		||||
        // here in onMessageReceived whether the app is in the foreground or background. Data
 | 
			
		||||
        // messages are the type
 | 
			
		||||
        // traditionally used with GCM. Notification messages are only received here in
 | 
			
		||||
        // onMessageReceived when the app
 | 
			
		||||
        // is in the foreground. When the app is in the background an automatically generated
 | 
			
		||||
        // notification is displayed.
 | 
			
		||||
        // When the user taps on the notification they are returned to the app. Messages
 | 
			
		||||
        // containing both notification
 | 
			
		||||
        // and data payloads are treated as notification messages. The Firebase console always
 | 
			
		||||
        // sends notification
 | 
			
		||||
        // messages. For more see: https://firebase.google.com/docs/cloud-messaging/concept-options
 | 
			
		||||
        // [END_EXCLUDE]
 | 
			
		||||
 | 
			
		||||
        // TODO(developer): Handle FCM messages here.
 | 
			
		||||
        // Not getting messages here? See why this may be: https://goo.gl/39bRNJ
 | 
			
		||||
        Log.d(TAG, "From: " + remoteMessage.getFrom());
 | 
			
		||||
 | 
			
		||||
        // Check if message contains a data payload.
 | 
			
		||||
        if (remoteMessage.getData().size() > 0) {
 | 
			
		||||
            Log.d(TAG, "Message data payload: " + remoteMessage.getData());
 | 
			
		||||
            sendNotification(remoteMessage.getData() + "");
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Check if message contains a notification payload.
 | 
			
		||||
        if (remoteMessage.getNotification() != null) {
 | 
			
		||||
            Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
 | 
			
		||||
            sendNotification(remoteMessage.getNotification().getBody());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Also if you intend on generating your own notifications as a result of a received FCM
 | 
			
		||||
        // message, here is where that should be initiated. See sendNotification method below.
 | 
			
		||||
        super.onMessageReceived(remoteMessage);
 | 
			
		||||
    }
 | 
			
		||||
    // [END receive_message]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // [START on_new_token]
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Called if InstanceID token is updated. This may occur if the security of
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								app/src/main/res/layout/activity_done_item.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								app/src/main/res/layout/activity_done_item.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
 | 
			
		||||
    android:layout_height="match_parent"
 | 
			
		||||
    tools:context=".activitys.DoneItemActivity">
 | 
			
		||||
 | 
			
		||||
    <android.support.v4.widget.SwipeRefreshLayout
 | 
			
		||||
        android:id="@+id/doneItemListRefresh"
 | 
			
		||||
        android:layout_width="0dp"
 | 
			
		||||
        android:layout_height="0dp"
 | 
			
		||||
        android:layout_marginStart="8dp"
 | 
			
		||||
        android:layout_marginTop="8dp"
 | 
			
		||||
        android:layout_marginEnd="8dp"
 | 
			
		||||
        android:layout_marginBottom="8dp"
 | 
			
		||||
        app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
        app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
        app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
        app:layout_constraintTop_toTopOf="parent">
 | 
			
		||||
 | 
			
		||||
        <android.support.v7.widget.RecyclerView
 | 
			
		||||
            android:id="@+id/doneitemsrecycle"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="match_parent"
 | 
			
		||||
            android:layout_marginStart="8dp"
 | 
			
		||||
            android:layout_marginTop="8dp"
 | 
			
		||||
            android:layout_marginEnd="8dp"
 | 
			
		||||
            android:layout_marginBottom="8dp"
 | 
			
		||||
            app:layout_constraintBottom_toBottomOf="parent"
 | 
			
		||||
            app:layout_constraintEnd_toEndOf="parent"
 | 
			
		||||
            app:layout_constraintStart_toStartOf="parent"
 | 
			
		||||
            app:layout_constraintTop_toTopOf="parent" />
 | 
			
		||||
 | 
			
		||||
    </android.support.v4.widget.SwipeRefreshLayout>
 | 
			
		||||
</android.support.constraint.ConstraintLayout>
 | 
			
		||||
@@ -4,6 +4,9 @@
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/addInvite"
 | 
			
		||||
        android:title="Insert Invite" />
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/doneEinkauf"
 | 
			
		||||
        android:title="Erledigte Einkäufe" />
 | 
			
		||||
    <item
 | 
			
		||||
        android:id="@+id/logoutBtn"
 | 
			
		||||
        android:title="Logout"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user