Showing
5 changed files
with
74 additions
and
1 deletions
... | @@ -9,7 +9,8 @@ | ... | @@ -9,7 +9,8 @@ |
9 | android:roundIcon="@mipmap/ic_launcher_round" | 9 | android:roundIcon="@mipmap/ic_launcher_round" |
10 | android:supportsRtl="true" | 10 | android:supportsRtl="true" |
11 | android:theme="@style/NoActionBar"> | 11 | android:theme="@style/NoActionBar"> |
12 | - <activity android:name=".DetailActivity"></activity> | 12 | + <activity android:name=".PushingActivity"></activity> |
13 | + <activity android:name=".DetailActivity" /> | ||
13 | <activity android:name=".InfoActivity" /> | 14 | <activity android:name=".InfoActivity" /> |
14 | <activity android:name=".FavoritesActivity" /> | 15 | <activity android:name=".FavoritesActivity" /> |
15 | <activity android:name=".RecommendActivity" /> | 16 | <activity android:name=".RecommendActivity" /> |
... | @@ -27,6 +28,8 @@ | ... | @@ -27,6 +28,8 @@ |
27 | <category android:name="android.intent.category.LAUNCHER" /> | 28 | <category android:name="android.intent.category.LAUNCHER" /> |
28 | </intent-filter> | 29 | </intent-filter> |
29 | </activity> | 30 | </activity> |
31 | + | ||
32 | + | ||
30 | </application> | 33 | </application> |
31 | 34 | ||
32 | </manifest> | 35 | </manifest> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | package com.example.vip | 1 | package com.example.vip |
2 | 2 | ||
3 | +import android.content.Intent | ||
3 | import androidx.appcompat.app.AppCompatActivity | 4 | import androidx.appcompat.app.AppCompatActivity |
4 | import android.os.Bundle | 5 | import android.os.Bundle |
5 | import android.widget.ImageView | 6 | import android.widget.ImageView |
6 | import android.widget.RatingBar | 7 | import android.widget.RatingBar |
7 | import android.widget.TextView | 8 | import android.widget.TextView |
9 | +import kotlinx.android.synthetic.main.activity_info.* | ||
8 | 10 | ||
9 | class InfoActivity : AppCompatActivity() { | 11 | class InfoActivity : AppCompatActivity() { |
10 | 12 | ||
... | @@ -22,5 +24,13 @@ class InfoActivity : AppCompatActivity() { | ... | @@ -22,5 +24,13 @@ class InfoActivity : AppCompatActivity() { |
22 | profilImage.setImageResource(R.drawable.image01) | 24 | profilImage.setImageResource(R.drawable.image01) |
23 | 25 | ||
24 | //temp | 26 | //temp |
27 | + | ||
28 | + | ||
29 | + //pushing test start | ||
30 | + InfoButtonSettings.setOnClickListener { | ||
31 | + var intent = Intent(this, PushingActivity::class.java) | ||
32 | + startActivity(intent) | ||
33 | + } | ||
34 | + //pushing test end | ||
25 | } | 35 | } |
26 | } | 36 | } | ... | ... |
1 | +package com.example.vip | ||
2 | + | ||
3 | +import androidx.appcompat.app.AppCompatActivity | ||
4 | +import android.os.Bundle | ||
5 | +import android.util.Log | ||
6 | +import android.widget.Toast | ||
7 | +import com.google.firebase.messaging.FirebaseMessaging | ||
8 | +import kotlinx.android.synthetic.main.activity_pushing.* | ||
9 | + | ||
10 | +class PushingActivity : AppCompatActivity() { | ||
11 | + | ||
12 | + override fun onCreate(savedInstanceState: Bundle?) { | ||
13 | + super.onCreate(savedInstanceState) | ||
14 | + setContentView(R.layout.activity_pushing) | ||
15 | + | ||
16 | + | ||
17 | + subscribeButton.setOnClickListener { | ||
18 | + Log.d(TAG, "Subscribing to weather topic") | ||
19 | + // [START subscribe_topics] | ||
20 | + FirebaseMessaging.getInstance().subscribeToTopic("news") | ||
21 | + .addOnCompleteListener { task -> | ||
22 | + var msg = getString(R.string.msg_subscribed) | ||
23 | + if (!task.isSuccessful) { | ||
24 | + msg = getString(R.string.msg_subscribe_failed) | ||
25 | + } | ||
26 | + Log.d(TAG, msg) | ||
27 | + Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() | ||
28 | + } | ||
29 | + // [END subscribe_topics] | ||
30 | + } | ||
31 | + } | ||
32 | + companion object { | ||
33 | + | ||
34 | + private const val TAG = "PushingActivity" | ||
35 | + } | ||
36 | +} |
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + xmlns:tools="http://schemas.android.com/tools" | ||
5 | + android:layout_width="match_parent" | ||
6 | + android:layout_height="match_parent" | ||
7 | + tools:context=".PushingActivity"> | ||
8 | + | ||
9 | + <Button | ||
10 | + android:id="@+id/subscribeButton" | ||
11 | + android:layout_width="wrap_content" | ||
12 | + android:layout_height="wrap_content" | ||
13 | + android:layout_marginStart="134dp" | ||
14 | + android:layout_marginTop="332dp" | ||
15 | + android:layout_marginEnd="189dp" | ||
16 | + android:layout_marginBottom="351dp" | ||
17 | + android:text="Button" | ||
18 | + app:layout_constraintBottom_toBottomOf="parent" | ||
19 | + app:layout_constraintEnd_toEndOf="parent" | ||
20 | + app:layout_constraintStart_toStartOf="parent" | ||
21 | + app:layout_constraintTop_toTopOf="parent" /> | ||
22 | +</androidx.constraintlayout.widget.ConstraintLayout> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -19,5 +19,7 @@ | ... | @@ -19,5 +19,7 @@ |
19 | 19 | ||
20 | <string name="msg_token_fmt" translatable="false">InstanceID Token: %s</string> | 20 | <string name="msg_token_fmt" translatable="false">InstanceID Token: %s</string> |
21 | 21 | ||
22 | + <string name="msg_subscribed" translatable="false">success!</string> | ||
23 | + <string name="msg_subscribe_failed" translatable="false">fail!</string> | ||
22 | 24 | ||
23 | </resources> | 25 | </resources> | ... | ... |
-
Please register or login to post a comment