// Path: app/src/main/java/org/secuso/privacyfriendlyweather/activities/CreateKeyActivity.java
// public class CreateKeyActivity extends AppCompatActivity {
// 
//     public static boolean active = false;
// 
//     RelativeLayout layout;
//     EditText personalKeyField;
//     Button keyButton;
//     Button abortButton;
//     Boolean fragmentShown = false;
// 
//     @Override
//     public void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         setContentView(R.layout.activity_create_key);
//         layout = findViewById(R.id.add_key_layout);
//         personalKeyField = findViewById(R.id.owm_key_field);
//         keyButton = findViewById(R.id.set_owm_key_button);
//         abortButton = findViewById(R.id.abort_button);
//         TextView introText = findViewById(R.id.explanation_text_owm_key);
//         boolean limitReached = getIntent().getBooleanExtra("429", false);
//         if (!limitReached) {
//             introText.setText(R.string.explanation_owm_key_on_start);
//         }
// 
//         keyButton.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 String currentValue = personalKeyField.getText().toString().replaceAll("[\\s\\u0085\\p{Z}]", "");
//                 Log.d("debugtag", "currentfalue3: " + currentValue);
//                 if (currentValue != null && currentValue.length() == 32) {
// 
//                     SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
//                     SharedPreferences.Editor editor = settings.edit();
//                     editor.putString("API_key_value", currentValue);
//                     editor.commit();
//                     leave();
//                 } else {
//                     Toast.makeText(getApplicationContext(), R.string.insert_correct_owm_key, Toast.LENGTH_LONG).show();
//                 }
//             }
//         });
// 
//         abortButton.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 onBackPressed();
//             }
//         });
// 
// 
//         Toolbar toolbar = findViewById(R.id.toolbar);
//         if (getSupportActionBar() == null) {
//             setSupportActionBar(toolbar);
//         }
//         getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//         getSupportActionBar().setDisplayShowHomeEnabled(true);
// 
//     }
// 
//     @Override
//     public boolean onSupportNavigateUp() {
//         onBackPressed();
//         return true;
//     }
// 
//     private void areYouSure() {
//         fragmentShown = true;
//         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//         ft.replace(R.id.are_you_sure_fragment, new AreYouSureFragment());
//         ft.commit();
//     }
// 
//     @Override
//     public void onBackPressed() {
//         if (fragmentShown) {
//             FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//             ft.remove(getSupportFragmentManager().findFragmentById(R.id.are_you_sure_fragment));
//             ft.commit();
//             fragmentShown = false;
//         } else {
//             areYouSure();
//         }
//     }
// 
//     public void leave() {
//         AppPreferencesManager prefManager = new AppPreferencesManager(PreferenceManager.getDefaultSharedPreferences(this));
//         prefManager.setAskedForOwmKey(true);
//         ForecastCityActivity.stopTurning = true;
//         if (isTaskRoot()) {
//             Intent mainIntent = new Intent(getApplicationContext(), ForecastCityActivity.class);
//             startActivity(mainIntent);
//         } else {
//             super.onBackPressed();
// 
//         }
//     }
// 
//     @Override
//     protected void onStart() {
//         super.onStart();
//         active = true;
//     }
// 
//     @Override
//     protected void onStop() {
//         super.onStop();
//         active = false;
//     }
// 
//     @Override
//     protected void onNewIntent(Intent intent) {
//         super.onNewIntent(intent);
//         setIntent(intent);
//     }
// }


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import org.secuso.privacyfriendlyweather.R;
import org.secuso.privacyfriendlyweather.activities.CreateKeyActivity;
package org.secuso.privacyfriendlyweather.ui;




public class AreYouSureFragment extends Fragment {

    Button shared;
    Button personal;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_are_you_sure, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        shared = view.findViewById(R.id.button_abort_personal_key);
        personal = view.findViewById(R.id.button_return_to_key);

        shared.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
// Path: app/src/main/java/org/secuso/privacyfriendlyweather/activities/CreateKeyActivity.java
// public class CreateKeyActivity extends AppCompatActivity {
// 
//     public static boolean active = false;
// 
//     RelativeLayout layout;
//     EditText personalKeyField;
//     Button keyButton;
//     Button abortButton;
//     Boolean fragmentShown = false;
// 
//     @Override
//     public void onCreate(@Nullable Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         setContentView(R.layout.activity_create_key);
//         layout = findViewById(R.id.add_key_layout);
//         personalKeyField = findViewById(R.id.owm_key_field);
//         keyButton = findViewById(R.id.set_owm_key_button);
//         abortButton = findViewById(R.id.abort_button);
//         TextView introText = findViewById(R.id.explanation_text_owm_key);
//         boolean limitReached = getIntent().getBooleanExtra("429", false);
//         if (!limitReached) {
//             introText.setText(R.string.explanation_owm_key_on_start);
//         }
// 
//         keyButton.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 String currentValue = personalKeyField.getText().toString().replaceAll("[\\s\\u0085\\p{Z}]", "");
//                 Log.d("debugtag", "currentfalue3: " + currentValue);
//                 if (currentValue != null && currentValue.length() == 32) {
// 
//                     SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
//                     SharedPreferences.Editor editor = settings.edit();
//                     editor.putString("API_key_value", currentValue);
//                     editor.commit();
//                     leave();
//                 } else {
//                     Toast.makeText(getApplicationContext(), R.string.insert_correct_owm_key, Toast.LENGTH_LONG).show();
//                 }
//             }
//         });
// 
//         abortButton.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 onBackPressed();
//             }
//         });
// 
// 
//         Toolbar toolbar = findViewById(R.id.toolbar);
//         if (getSupportActionBar() == null) {
//             setSupportActionBar(toolbar);
//         }
//         getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//         getSupportActionBar().setDisplayShowHomeEnabled(true);
// 
//     }
// 
//     @Override
//     public boolean onSupportNavigateUp() {
//         onBackPressed();
//         return true;
//     }
// 
//     private void areYouSure() {
//         fragmentShown = true;
//         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//         ft.replace(R.id.are_you_sure_fragment, new AreYouSureFragment());
//         ft.commit();
//     }
// 
//     @Override
//     public void onBackPressed() {
//         if (fragmentShown) {
//             FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
//             ft.remove(getSupportFragmentManager().findFragmentById(R.id.are_you_sure_fragment));
//             ft.commit();
//             fragmentShown = false;
//         } else {
//             areYouSure();
//         }
//     }
// 
//     public void leave() {
//         AppPreferencesManager prefManager = new AppPreferencesManager(PreferenceManager.getDefaultSharedPreferences(this));
//         prefManager.setAskedForOwmKey(true);
//         ForecastCityActivity.stopTurning = true;
//         if (isTaskRoot()) {
//             Intent mainIntent = new Intent(getApplicationContext(), ForecastCityActivity.class);
//             startActivity(mainIntent);
//         } else {
//             super.onBackPressed();
// 
//         }
//     }
// 
//     @Override
//     protected void onStart() {
//         super.onStart();
//         active = true;
//     }
// 
//     @Override
//     protected void onStop() {
//         super.onStop();
//         active = false;
//     }
// 
//     @Override
//     protected void onNewIntent(Intent intent) {
//         super.onNewIntent(intent);
//         setIntent(intent);
//     }
// }


// Path: app/src/main/java/org/secuso/privacyfriendlyweather/ui/AreYouSureFragment.java
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import org.secuso.privacyfriendlyweather.R;
import org.secuso.privacyfriendlyweather.activities.CreateKeyActivity;

package org.secuso.privacyfriendlyweather.ui;




public class AreYouSureFragment extends Fragment {

    Button shared;
    Button personal;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_are_you_sure, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        shared = view.findViewById(R.id.button_abort_personal_key);
        personal = view.findViewById(R.id.button_return_to_key);

        shared.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((CreateKeyActivity) getActivity()).leave();