rk
昨天 4a8ff39b0fab0627ef8f7459587d514cc01c3676
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package com.example.settinglibrary;
 
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.PopupWindow;
import android.widget.Switch;
import android.widget.TextView;
import com.example.datalibrary.activity.BaseActivity;
import com.example.datalibrary.utils.PWTextUtils;
 
public class PictureOptimizationActivity extends BaseActivity {
    private Switch swDarkEnhance;
    private Switch swBestImage;
    private Button tipsdarkEnhance;
    private Button tipsBestImage;
    private View groupdarkEnhance;
    private View groupBestImage;
    private TextView tvdarkEnhance;
    private TextView tvBestImage;
    private View groupFundarkEnhance;
    private String msgTag = "";
    private int showWidth;
    private int showXLocation;
    private boolean darkEnhance;
    private boolean bestImage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_picture_optimization);
        init();
        initListener();
    }
    private void init(){
        Intent intent = getIntent();
        darkEnhance = intent.getBooleanExtra("darkEnhance" , false);
        bestImage = intent.getBooleanExtra("bestImage" , false);
 
        swDarkEnhance = findViewById(R.id.sw_dark_enhance);
        swBestImage = findViewById(R.id.sw_best_image);
        // 暗光恢复开关
        tipsdarkEnhance = findViewById(R.id.tips_dark_enhance);
        tvdarkEnhance = findViewById(R.id.tv_dark_enhance);
        groupdarkEnhance = findViewById(R.id.group_dark_enhance);
        groupFundarkEnhance = findViewById(R.id.group_fun_dark_enhance);
        // best image开关
        tipsBestImage = findViewById(R.id.tips_best_image);
        groupBestImage = findViewById(R.id.group_best_image);
        tvBestImage = findViewById(R.id.tv_best_image);
        if (darkEnhance) {
            swDarkEnhance.setChecked(true);
        } else {
            swDarkEnhance.setChecked(false);
        }
        if (bestImage) {
            swBestImage.setChecked(true);
        } else {
            swBestImage.setChecked(false);
        }
    }
    private void initListener(){
        tipsdarkEnhance.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (msgTag.equals(getString(R.string.cw_darkEnhance))) {
                    msgTag = "";
                    return;
                }
                msgTag = getString(R.string.cw_darkEnhance);
                tipsdarkEnhance.setBackground(getDrawable(R.mipmap.icon_setting_question_hl));
                PWTextUtils.showDescribeText(groupFundarkEnhance, tvdarkEnhance, PictureOptimizationActivity.this,
                        getString(R.string.cw_darkEnhance), showWidth, showXLocation);
            }
        });
        tipsBestImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (msgTag.equals(getString(R.string.cw_bestimage))) {
                    msgTag = "";
                    return;
                }
                msgTag = getString(R.string.cw_bestimage);
                tipsBestImage.setBackground(getDrawable(R.mipmap.icon_setting_question_hl));
                PWTextUtils.showDescribeText(groupBestImage, tvBestImage, PictureOptimizationActivity.this,
                        getString(R.string.cw_bestimage), showWidth, showXLocation);
            }
        });
        PWTextUtils.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @SuppressLint("NewApi")
            @Override
            public void onDismiss() {
                tipsBestImage.setBackground(getDrawable(R.mipmap.icon_setting_question));
                tipsdarkEnhance.setBackground(getDrawable(R.mipmap.icon_setting_question));
            }
        });
 
        findViewById(R.id.qc_save).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (swDarkEnhance.isChecked()) {
                    darkEnhance = true;
                } else {
                    darkEnhance = false;
                }
                if (swBestImage.isChecked()) {
                    bestImage = true;
                } else {
                    bestImage = false;
                }
                finish();
            }
        });
    }
 
    @Override
    public void finish() {
        Intent intent = new Intent();
        intent.putExtra("darkEnhance", darkEnhance);
        intent.putExtra("bestImage", bestImage);
        // 设置返回码和返回携带的数据
        setResult(Activity.RESULT_OK, intent);
        super.finish();
    }
 
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        showWidth = groupFundarkEnhance.getWidth();
        showXLocation = (int) groupdarkEnhance.getX();
    }
}