This repository was archived by the owner on Aug 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 413
Expand file tree
/
Copy pathPopupSettingsView.java
More file actions
77 lines (69 loc) · 2.54 KB
/
PopupSettingsView.java
File metadata and controls
77 lines (69 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.snatik.matches.ui;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.snatik.matches.R;
import com.snatik.matches.common.Music;
import com.snatik.matches.common.Shared;
import com.snatik.matches.utils.FontLoader;
import com.snatik.matches.utils.FontLoader.Font;
public class PopupSettingsView extends LinearLayout{
private ImageView mSoundImage;
private TextView mSoundText;
public PopupSettingsView(Context context) {
this(context, null);
}
public PopupSettingsView(Context context, AttributeSet attrs) {
super(context, attrs);
if(Music.OFF) Music.stopBackgroundMusic();
setOrientation(LinearLayout.VERTICAL);
setBackgroundResource(R.drawable.settings_popup);
LayoutInflater.from(getContext()).inflate(R.layout.popup_settings_view, this, true);
mSoundText = (TextView) findViewById(R.id.sound_off_text);
mSoundText.setText("Sound OFF");
TextView rateView = (TextView) findViewById(R.id.rate_text);
FontLoader.setTypeface(context, new TextView[] { mSoundText, rateView }, Font.GROBOLD);
mSoundImage = (ImageView) findViewById(R.id.sound_image);
mSoundImage.setImageResource(R.drawable.button_music_off);
View soundOff = findViewById(R.id.sound_off);
soundOff.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setMusicButton();
Music.OFF = !Music.OFF;
}
});
View rate = findViewById(R.id.rate);
rate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String appPackageName = Shared.context.getPackageName();
try {
Shared.activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
Shared.activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
});
}
private void setMusicButton() {
if (Music.OFF) {
mSoundText.setText("Sound OFF");
mSoundImage.setImageResource(R.drawable.button_music_off);
Music.stopBackgroundMusic();
} else {
mSoundText.setText("Sound ON");
mSoundImage.setImageResource(R.drawable.button_music_on);
Music.playBackgroundMusic();
}
}
}