2019-06-03 23:25:05 +02:00
|
|
|
package org.mian.gitnex.fragments;
|
|
|
|
|
2020-09-27 09:36:57 +02:00
|
|
|
import android.content.ActivityNotFoundException;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.content.Intent;
|
2020-09-27 09:36:57 +02:00
|
|
|
import android.net.Uri;
|
2019-06-03 23:25:05 +02:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.LinearLayout;
|
2020-04-07 22:39:08 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.fragment.app.Fragment;
|
2019-06-03 23:25:05 +02:00
|
|
|
import org.mian.gitnex.R;
|
2020-10-23 20:13:13 +02:00
|
|
|
import org.mian.gitnex.activities.MainActivity;
|
2020-04-26 15:36:33 +02:00
|
|
|
import org.mian.gitnex.activities.SettingsAppearanceActivity;
|
2020-07-09 13:55:09 +02:00
|
|
|
import org.mian.gitnex.activities.SettingsDraftsActivity;
|
2020-04-26 15:36:33 +02:00
|
|
|
import org.mian.gitnex.activities.SettingsFileViewerActivity;
|
2020-10-23 20:13:13 +02:00
|
|
|
import org.mian.gitnex.activities.SettingsGeneralActivity;
|
2020-04-26 15:36:33 +02:00
|
|
|
import org.mian.gitnex.activities.SettingsReportsActivity;
|
|
|
|
import org.mian.gitnex.activities.SettingsSecurityActivity;
|
|
|
|
import org.mian.gitnex.activities.SettingsTranslationActivity;
|
2020-07-07 19:15:01 +02:00
|
|
|
import org.mian.gitnex.helpers.TinyDB;
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Author M M Arif
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class SettingsFragment extends Fragment {
|
|
|
|
|
2020-04-07 22:39:08 +02:00
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
2019-06-03 23:25:05 +02:00
|
|
|
|
2020-04-07 22:39:08 +02:00
|
|
|
View v = inflater.inflate(R.layout.fragment_settings, container, false);
|
2020-03-05 21:56:42 +01:00
|
|
|
|
2020-10-23 20:13:13 +02:00
|
|
|
((MainActivity) requireActivity()).setActionBarTitle(getResources().getString(R.string.navSettings));
|
|
|
|
|
|
|
|
LinearLayout generalFrame = v.findViewById(R.id.generalFrame);
|
2020-05-14 12:46:49 +02:00
|
|
|
LinearLayout appearanceFrame = v.findViewById(R.id.appearanceFrame);
|
2020-04-26 15:36:33 +02:00
|
|
|
LinearLayout fileViewerFrame = v.findViewById(R.id.fileViewerFrame);
|
2020-07-09 13:55:09 +02:00
|
|
|
LinearLayout draftsFrame = v.findViewById(R.id.draftsFrame);
|
2020-04-26 15:36:33 +02:00
|
|
|
LinearLayout securityFrame = v.findViewById(R.id.securityFrame);
|
|
|
|
LinearLayout languagesFrame = v.findViewById(R.id.languagesFrame);
|
|
|
|
LinearLayout reportsFrame = v.findViewById(R.id.reportsFrame);
|
2020-09-27 09:36:57 +02:00
|
|
|
LinearLayout rateAppFrame = v.findViewById(R.id.rateAppFrame);
|
|
|
|
LinearLayout aboutAppFrame = v.findViewById(R.id.aboutAppFrame);
|
2020-03-06 14:46:22 +01:00
|
|
|
|
2020-10-23 20:13:13 +02:00
|
|
|
generalFrame.setOnClickListener(generalFrameCall -> startActivity(new Intent(getContext(), SettingsGeneralActivity.class)));
|
|
|
|
|
2020-05-14 12:46:49 +02:00
|
|
|
appearanceFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsAppearanceActivity.class)));
|
2020-04-02 02:59:00 +02:00
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
fileViewerFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsFileViewerActivity.class)));
|
2020-04-02 02:59:00 +02:00
|
|
|
|
2020-07-09 13:55:09 +02:00
|
|
|
draftsFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsDraftsActivity.class)));
|
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
securityFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsSecurityActivity.class)));
|
2020-04-04 21:20:25 +02:00
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
languagesFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsTranslationActivity.class)));
|
2020-04-04 21:20:25 +02:00
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
reportsFrame.setOnClickListener(v1 -> startActivity(new Intent(getContext(), SettingsReportsActivity.class)));
|
2020-04-07 22:39:08 +02:00
|
|
|
|
2020-09-27 09:36:57 +02:00
|
|
|
rateAppFrame.setOnClickListener(aboutApp -> rateThisApp());
|
|
|
|
|
|
|
|
aboutAppFrame.setOnClickListener(aboutApp -> requireActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new AboutFragment()).commit());
|
|
|
|
|
2020-04-07 22:39:08 +02:00
|
|
|
return v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-27 09:36:57 +02:00
|
|
|
public void rateThisApp() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + requireActivity().getPackageName())));
|
|
|
|
}
|
|
|
|
catch(ActivityNotFoundException e) {
|
|
|
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + requireActivity().getPackageName())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 22:39:08 +02:00
|
|
|
@Override
|
2020-04-26 15:36:33 +02:00
|
|
|
public void onResume() {
|
|
|
|
|
|
|
|
super.onResume();
|
2020-04-07 22:39:08 +02:00
|
|
|
|
2020-04-26 15:36:33 +02:00
|
|
|
TinyDB tinyDb = new TinyDB(getContext());
|
|
|
|
|
|
|
|
if(tinyDb.getBoolean("refreshParent")) {
|
2020-09-27 09:36:57 +02:00
|
|
|
requireActivity().recreate();
|
|
|
|
requireActivity().overridePendingTransition(0, 0);
|
2020-04-26 15:36:33 +02:00
|
|
|
tinyDb.putBoolean("refreshParent", false);
|
|
|
|
}
|
2020-04-07 22:39:08 +02:00
|
|
|
|
|
|
|
}
|
2019-06-03 23:25:05 +02:00
|
|
|
|
|
|
|
}
|