Skip to content

Commit

Permalink
Fixed more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vatbub committed Feb 11, 2018
1 parent 63a4e8f commit ce740c5
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 30 deletions.
110 changes: 110 additions & 0 deletions .idea/dictionaries/frede.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SUPERPOWERED-LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Spuerpowered License
# Superpowered License

The following document details the Superpowered Audio SDK license agreement as of September 6, 2016.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ private void openFragment(String tag, Fragment initialFragmentInstance) {
private void updateTitle(String fragmentTag) {
switch (fragmentTag) {
case "streamingFragment":
setTitle(getString(R.string.fragment_streaming_titile));
setTitle(getString(R.string.fragment_streaming_title));
break;
case "privacyFragment":
setTitle(getString(R.string.fragment_privacy_titile));
setTitle(getString(R.string.fragment_privacy_title));
break;
case "aboutFragment":
setTitle(getString(R.string.fragment_about_title));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import android.os.Bundle;
import android.app.Fragment;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -26,7 +27,7 @@ public AboutFragment() {


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_about, container, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;
Expand All @@ -14,7 +15,7 @@ public class CustomFragment extends Fragment {
private View createdView;

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
createdView = view;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.vatbub.hearingaid.fragments;

import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.text.InputType;
Expand All @@ -19,6 +21,7 @@
import android.widget.Switch;
import android.widget.TextView;

import com.crashlytics.android.Crashlytics;
import com.github.vatbub.hearingaid.MainActivity;
import com.github.vatbub.hearingaid.ProfileManager;
import com.github.vatbub.hearingaid.R;
Expand All @@ -34,7 +37,7 @@ public SettingsFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
setHasOptionsMenu(true);
Expand Down Expand Up @@ -91,11 +94,22 @@ public boolean onOptionsItemSelected(MenuItem item) {
}

private void addProfile() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
Context context = getContext();
final MainActivity activity = (MainActivity) getActivity();
if (context==null){
Crashlytics.logException(new NullPointerException("context was null"));
return;
}
if (activity==null){
Crashlytics.logException(new NullPointerException("Activity was null"));
return;
}

AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(getString(R.string.fragment_settings_current_profile_add));

// Set up the input
final EditText input = new EditText(getContext());
final EditText input = new EditText(context);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_TEXT);
builder.setView(input);
Expand All @@ -105,9 +119,9 @@ private void addProfile() {
@Override
public void onClick(DialogInterface dialog, int which) {
ProfileManager.Profile createdProfile = ProfileManager.getInstance(getActivity()).createProfile(input.getText().toString());
((MainActivity) getActivity()).getProfileAdapter().add(createdProfile);
activity.getProfileAdapter().add(createdProfile);
getProfileAdapter().add(createdProfile);
ProfileManager.getInstance(getActivity()).applyProfile(createdProfile);
ProfileManager.getInstance(activity).applyProfile(createdProfile);
}
});
builder.setNegativeButton(getString(R.string.fragment_settings_add_profile_cancel), new DialogInterface.OnClickListener() {
Expand All @@ -121,23 +135,38 @@ public void onClick(DialogInterface dialog, int which) {
}

private void renameProfile() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
Context context = getContext();
final MainActivity activity = (MainActivity) getActivity();
final ProfileManager.Profile currentProfile = ProfileManager.getInstance(getActivity()).getCurrentlyActiveProfile();
if (context==null){
Crashlytics.logException(new NullPointerException("context was null"));
return;
}
if (activity==null){
Crashlytics.logException(new NullPointerException("Activity was null"));
return;
}
if (currentProfile==null){
Crashlytics.logException(new NullPointerException("Current Profile was null"));
return;
}

AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(getString(R.string.fragment_settings_current_profile_rename));

// Set up the input
final EditText input = new EditText(getContext());
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_TEXT);
input.setText(ProfileManager.getInstance(getActivity()).getCurrentlyActiveProfile().getProfileName());
input.setText(currentProfile.getProfileName());
builder.setView(input);

// Set up the buttons
builder.setPositiveButton(getString(R.string.fragment_settings_rename_profile_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ProfileManager.Profile currentProfile = ProfileManager.getInstance(getActivity()).getCurrentlyActiveProfile();
currentProfile.setProfileName(input.getText().toString());
((MainActivity) getActivity()).initProfileAdapter();
activity.initProfileAdapter();
initProfileAdapter();
}
});
Expand All @@ -152,9 +181,15 @@ public void onClick(DialogInterface dialog, int which) {
}

private void removeProfile() {
final MainActivity activity = (MainActivity) getActivity();
if (activity==null){
Crashlytics.logException(new NullPointerException("Activity was null"));
return;
}

ProfileManager.Profile currentProfile = ProfileManager.getInstance(getActivity()).getCurrentlyActiveProfile();
ProfileManager.getInstance(getActivity()).deleteProfile(currentProfile);
((MainActivity) getActivity()).getProfileAdapter().remove(currentProfile);
activity.getProfileAdapter().remove(currentProfile);
getProfileAdapter().remove(currentProfile);
ProfileManager.getInstance(getActivity()).applyProfile(ProfileManager.getInstance(getActivity()).listProfiles().get(0));
}
Expand Down Expand Up @@ -216,9 +251,10 @@ public void onChanged(@Nullable ProfileManager.Profile oldProfile, @Nullable Pro

private void updateEqSwitch() {
Switch eqSwitch = findViewById(R.id.eq_on_off_switch);
ProfileManager.Profile currentProfile = ProfileManager.getInstance(getContext()).getCurrentlyActiveProfile();
if (eqSwitch == null) return;
if (ProfileManager.getInstance(getContext()).getCurrentlyActiveProfile() == null) return;
eqSwitch.setChecked(ProfileManager.getInstance(getContext()).getCurrentlyActiveProfile().isEqEnabled());
if (currentProfile == null) return;
eqSwitch.setChecked(currentProfile.isEqEnabled());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ private void showPlayPauseNotification() {
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(SUPERPOWERED_INITIALIZED_BUNDLE_KEY, superpoweredInitialized);
outState.putBoolean(IS_STREAMING_BUNDLE_KEY, isStreamingEnabled());
outState.putBoolean(NOTIFICATION_SHOWN_KEY, notificationShown);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_streaming, container, false);
Expand Down Expand Up @@ -387,7 +387,9 @@ public void notifyEQEnabledSettingChanged() {
if (!superpoweredInitialized)
return;

eqEnabled(ProfileManager.getInstance(getActivity()).getCurrentlyActiveProfile().isEqEnabled());
ProfileManager.Profile currentProfile = ProfileManager.getInstance(getContext()).getCurrentlyActiveProfile();
if (currentProfile != null)
eqEnabled(currentProfile.isEqEnabled());
}

@Override
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/menu/fragment_settings_options.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">

<item
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"></menu>
<menu />
4 changes: 2 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<string name="nav_share">Teilen</string>
<string name="nav_feedback">Feedback</string>
<string name="nav_communicate">Kommunizieren</string>
<string name="fragment_privacy_titile">Datenschutz</string>
<string name="fragment_streaming_titile">Hörgerät</string>
<string name="fragment_privacy_title">Datenschutz</string>
<string name="fragment_streaming_title">Hörgerät</string>
<string name="nav_streaming">Start</string>
<string name="fragment_about_title">Impressum</string>
<string name="fragment_streaming_snackbar_start_streaming">Hörgerät eingeschaltet</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/drawables.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<resources>
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<string name="nav_share">Share</string>
<string name="nav_feedback">Feedback</string>
<string name="nav_communicate">Communicate</string>
<string name="fragment_privacy_titile">Privacy</string>
<string name="fragment_privacy_title">Privacy</string>

<!-- TODO: Remove or change this placeholder text -->
<string name="fragment_streaming_titile">Hearing Aid</string>
<string name="fragment_streaming_title">Hearing Aid</string>
<string name="nav_streaming">Main</string>

<!-- TODO: Remove or change this placeholder text -->
Expand Down

0 comments on commit ce740c5

Please sign in to comment.