正在查看: St.John's v1.0.9 应用的 SettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 SettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.settings;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;
import androidx.fragment.app.FragmentActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.jaredrummler.android.colorpicker.ColorPickerDialog;
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener;
import com.mcb.stjohnsemschool.activity.ChangePasswordActivity;
import com.mcb.stjohnsemschool.activity.NotificationHelpActivity;
import com.mcb.stjohnsemschool.activity.RateYourSchoolActivity;
import com.mcb.stjohnsemschool.activity.ReviewAndRatingActivity;
import com.mcb.stjohnsemschool.model.ParentAppSettingsModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.mcxiaoke.koi.Const;
import com.microsoft.identity.common.java.eststelemetry.SchemaConstants;
import cz.msebera.android.httpclient.protocol.HTTP;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class SettingsActivity extends FragmentActivity implements CompoundButton.OnCheckedChangeListener, ColorPickerDialogListener, View.OnClickListener {
private int DIALOG_ID = 9;
private SettingsActivity activity;
private String branchName;
private Context context;
private boolean isCalenderSyncEnabled;
private boolean isNotificationEnabled;
private boolean isNotificationSoundEnabled;
private String mAppVersionStr;
private TextView mAppVersionTv;
private ImageView mBackArrowIv;
private TextView mChangePassword;
private String mContentStr;
private SharedPreferences.Editor mEditor;
private TextView mNotificationHelp;
private TextView mNotificationSettings;
private Switch mNotificationSoundSw;
private Switch mNotificationsSw;
private RelativeLayout mPrivacyRl;
private TransparentProgressDialog mProgressbar;
private TextView mRateYourSchool;
private TextView mReviewAndRating;
private LinearLayout mReviewAndRatingLL;
private ImageView mSelectedIconColorIv;
private TextView mSendFeedback;
private SharedPreferences mSharedPref;
private String mSubjectStr;
private RelativeLayout mThemeRl;
private RelativeLayout mTopRL;
private String orgName;
public void onDialogDismissed(int i) {
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(2131558537);
findViewById(2131363832);
this.activity = this;
this.context = getApplicationContext();
init();
}
private void init() {
SharedPreferences sharedPreferences = getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.mEditor = sharedPreferences.edit();
this.mProgressbar = new TransparentProgressDialog(this, 2131231479);
this.isNotificationEnabled = this.mSharedPref.getBoolean(Constants.KEY_NOTIFICATION, true);
this.isNotificationSoundEnabled = this.mSharedPref.getBoolean(Constants.KEY_NOTIFICATION_SOUND, false);
this.isCalenderSyncEnabled = this.mSharedPref.getBoolean(Constants.KEY_CALENDER_SYNC, false);
this.branchName = this.mSharedPref.getString("branchnameKey", this.branchName);
this.orgName = this.mSharedPref.getString("OrganisationNameKey", this.orgName);
String string = this.mSharedPref.getString("EnrollmentCode", "");
String string2 = this.mSharedPref.getString("Class", "");
String string3 = this.mSharedPref.getString("SectionNameKey", "");
this.mNotificationsSw = (Switch) findViewById(2131363182);
this.mNotificationSoundSw = (Switch) findViewById(2131363181);
this.mNotificationHelp = (TextView) findViewById(2131364245);
this.mNotificationSettings = (TextView) findViewById(2131364246);
this.mReviewAndRatingLL = (LinearLayout) findViewById(2131362911);
this.mReviewAndRating = (TextView) findViewById(2131364333);
this.mChangePassword = (TextView) findViewById(2131363991);
this.mNotificationHelp = (TextView) findViewById(2131364245);
this.mSendFeedback = (TextView) findViewById(2131364343);
this.mRateYourSchool = (TextView) findViewById(2131364316);
this.mNotificationSettings.setOnClickListener(this);
this.mSendFeedback.setOnClickListener(this);
this.mRateYourSchool.setOnClickListener(this);
this.mNotificationHelp.setOnClickListener(this);
this.mReviewAndRatingLL.setOnClickListener(this);
this.mReviewAndRating.setOnClickListener(this);
this.mChangePassword.setOnClickListener(this);
this.mNotificationHelp.setPaintFlags(8);
this.mSelectedIconColorIv = (ImageView) findViewById(2131362173);
this.mAppVersionTv = (TextView) findViewById(2131361939);
this.mPrivacyRl = (RelativeLayout) findViewById(2131363300);
this.mTopRL = (RelativeLayout) findViewById(2131363840);
this.mBackArrowIv = (ImageView) findViewById(2131363600);
this.mThemeRl = (RelativeLayout) findViewById(2131363789);
this.mSendFeedback = (TextView) findViewById(2131364343);
this.mNotificationsSw.setOnCheckedChangeListener(this);
this.mNotificationSoundSw.setOnCheckedChangeListener(this);
this.mBackArrowIv.setOnClickListener(this);
this.mThemeRl.setOnClickListener(this);
this.mSendFeedback.setOnClickListener(this);
this.mNotificationsSw.setChecked(this.isNotificationEnabled);
this.mNotificationSoundSw.setChecked(this.isNotificationSoundEnabled);
this.mSelectedIconColorIv.setOnClickListener(this);
this.mPrivacyRl.setOnClickListener(this);
String str = "V " + Constants.getAppCurrentVersion(getApplicationContext());
this.mAppVersionStr = str;
this.mAppVersionTv.setText(str);
this.mSelectedIconColorIv.setBackgroundColor(this.mSharedPref.getInt(Constants.KEY_PRIMARY_COLOR, getResources().getColor(2131099650)));
this.mTopRL.setBackgroundColor(this.mSharedPref.getInt(Constants.KEY_PRIMARY_COLOR, getResources().getColor(2131099650)));
this.mSubjectStr = this.context.getResources().getString(2131886124) + " App Feedback";
this.mContentStr = "\n\n\n -------------------------------------------\nBranch : " + this.branchName + Const.LINE_SEPARATOR + string + Const.LINE_SEPARATOR + string2 + " - " + string3 + "\nAndroid App Version : " + this.mAppVersionStr + "\n Model : " + Build.MODEL + "\n Manufacturer : " + Build.MANUFACTURER;
getParentAppSettings();
}
private void loadPrivacy() {
startActivity(new Intent("android.intent.action.VIEW", Uri.parse(getResources().getString(2131886328))));
}
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
switch (compoundButton.getId()) {
case 2131363181:
this.mEditor.putBoolean(Constants.KEY_NOTIFICATION_SOUND, z);
this.mEditor.commit();
break;
case 2131363182:
this.mEditor.putBoolean(Constants.KEY_NOTIFICATION, z);
this.mEditor.commit();
break;
}
}
public void onColorSelected(int i, int i2) {
this.mEditor.putInt(Constants.KEY_PRIMARY_COLOR, i2);
this.mEditor.putInt(Constants.KEY_DARK_COLOR, Constants.getDarkColor(i2));
this.mEditor.commit();
int i3 = this.mSharedPref.getInt(Constants.KEY_PRIMARY_COLOR, -16777216);
this.mSelectedIconColorIv.setBackgroundColor(i3);
this.mTopRL.setBackgroundColor(i3);
}
@Override
public void onClick(View view) {
if (view.getId() == 2131364246) {
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("app_package", getPackageName());
intent.putExtra("app_uid", getApplicationInfo().uid);
intent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName());
startActivity(intent);
return;
}
if (view.getId() == 2131363300) {
loadPrivacy();
return;
}
if (view.getId() == 2131362173) {
showColorSelectingDialog();
return;
}
if (view.getId() == 2131363789) {
showColorSelectingDialog();
return;
}
if (view.getId() == 2131363600) {
finish();
return;
}
if (view.getId() == 2131364343) {
sendFeedback(new String[]{"[email protected]"}, this.mSubjectStr, this.mContentStr);
return;
}
if (view.getId() == 2131364245) {
Intent intent2 = new Intent(getApplicationContext(), (Class<?>) NotificationHelpActivity.class);
intent2.putExtra("URL", "https://kb.myclassboard.com/notifications/notifications/");
startActivity(intent2);
} else if (view.getId() == 2131362911 || view.getId() == 2131364333) {
startActivity(new Intent(getApplicationContext(), (Class<?>) ReviewAndRatingActivity.class));
} else if (view == this.mChangePassword) {
startActivity(new Intent(getApplicationContext(), (Class<?>) ChangePasswordActivity.class));
} else if (view.getId() == 2131364316) {
startActivity(new Intent(getApplicationContext(), (Class<?>) RateYourSchoolActivity.class));
}
}
private void showColorSelectingDialog() {
try {
ColorPickerDialog.newBuilder().setDialogType(0).setAllowPresets(false).setDialogId(this.DIALOG_ID).setColor(this.mSharedPref.getInt(Constants.KEY_PRIMARY_COLOR, getResources().getColor(2131099650))).setShowAlphaSlider(true).show(this);
} catch (Exception e) {
e.printStackTrace();
}
}
public void sendFeedback(String[] strArr, String str, String str2) {
Intent intent = new Intent("android.intent.action.SEND");
intent.putExtra("android.intent.extra.EMAIL", strArr);
intent.putExtra("android.intent.extra.SUBJECT", str);
intent.setType(HTTP.PLAIN_TEXT_TYPE);
intent.putExtra("android.intent.extra.TEXT", str2);
ResolveInfo resolveInfo = null;
for (ResolveInfo resolveInfo2 : getApplicationContext().getPackageManager().queryIntentActivities(intent, 0)) {
if (resolveInfo2.activityInfo.packageName.endsWith(".gm") || resolveInfo2.activityInfo.name.toLowerCase().contains("gmail")) {
resolveInfo = resolveInfo2;
}
}
if (resolveInfo != null) {
intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
}
startActivity(intent);
}
protected void onResume() {
super.onResume();
FirebaseAnalytics.getInstance(this).setCurrentScreen(this, Constants.FIREBASE_PAGE_SETTINGS, (String) null);
}
private void getParentAppSettings() {
if (Utility.hasNetworkConnection(this.context)) {
getAppSettings();
} else {
Utility.showInfoDialog(this.activity, Constants.NETWORK_ERROR);
}
}
private void getAppSettings() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
SharedPreferences sharedPrefs = Utility.getSharedPrefs(this.context);
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetParentAppSettings(Integer.parseInt(sharedPrefs.getString("orgnizationIdKey", SchemaConstants.Value.FALSE)), Integer.parseInt(sharedPrefs.getString("BranchIdKey", SchemaConstants.Value.FALSE)), Integer.parseInt(sharedPrefs.getString("UseridKey", SchemaConstants.Value.FALSE)), Integer.parseInt(sharedPrefs.getString("studentEnrollmentIdKey", SchemaConstants.Value.FALSE)), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<ParentAppSettingsModel>>() {
public void onResponse(Call<ArrayList<ParentAppSettingsModel>> call, Response<ArrayList<ParentAppSettingsModel>> response) {
if (SettingsActivity.this.mProgressbar != null && SettingsActivity.this.mProgressbar.isShowing()) {
SettingsActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(SettingsActivity.this.activity);
return;
}
ArrayList arrayList = (ArrayList) response.body();
if (arrayList.size() > 0) {
if (((ParentAppSettingsModel) arrayList.get(0)).isVisibility()) {
SettingsActivity.this.mReviewAndRatingLL.setVisibility(0);
} else {
SettingsActivity.this.mReviewAndRatingLL.setVisibility(8);
}
}
}
public void onFailure(Call<ArrayList<ParentAppSettingsModel>> call, Throwable th) {
if (SettingsActivity.this.mProgressbar != null && SettingsActivity.this.mProgressbar.isShowing()) {
SettingsActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(SettingsActivity.this.activity);
}
});
}
}