Skip to content

Commit

Permalink
Fragments moved into package fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
mkulesh committed Oct 27, 2020
1 parent 3abece7 commit d80f761
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 28 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/mkulesh/mmd/MMDWallpaperService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.view.SurfaceHolder;
import android.view.WindowManager;

import com.mkulesh.mmd.fragments.Experiment;
import com.mkulesh.mmd.utils.ViewUtils;

import androidx.preference.PreferenceManager;
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/mkulesh/mmd/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
import android.widget.Toast;

import com.google.android.material.navigation.NavigationView;
import com.mkulesh.mmd.fragments.BaseFragment;
import com.mkulesh.mmd.fragments.Experiment;
import com.mkulesh.mmd.fragments.MainFragmentExperiment;
import com.mkulesh.mmd.fragments.MainFragmentPotential;
import com.mkulesh.mmd.utils.CompatUtils;
import com.mkulesh.mmd.utils.ViewUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Public License along with this program.
*/

package com.mkulesh.mmd;
package com.mkulesh.mmd.fragments;

import android.app.WallpaperManager;
import android.content.Context;
Expand All @@ -31,6 +31,7 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mkulesh.mmd.R;
import com.mkulesh.mmd.config.SettingsActivity;
import com.mkulesh.mmd.model.Atom;
import com.mkulesh.mmd.model.AtomSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
* Public License along with this program.
*/

package com.mkulesh.mmd;
package com.mkulesh.mmd.fragments;

import android.content.SharedPreferences;
import android.view.View;

import com.mkulesh.mmd.MainActivity;

import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceManager;

abstract class BaseFragment extends Fragment
public abstract class BaseFragment extends Fragment
{
/**
* Class members.
*/
final static int INVALID_FRAGMENT_ID = -1;
public final static int INVALID_FRAGMENT_ID = -1;
final static int EXPERIMENT_FRAGMENT_ID = 0;
final static int POTENTIAL_FRAGMENT_ID = 1;

Expand All @@ -43,7 +45,7 @@ abstract class BaseFragment extends Fragment

abstract public int getSubTitleId();

int getFragmentNumber()
public int getFragmentNumber()
{
return fragmentNumber;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
* Public License along with this program.
*/

package com.mkulesh.mmd;
package com.mkulesh.mmd.fragments;

import android.content.Context;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.SurfaceHolder;

import com.mkulesh.mmd.R;
import com.mkulesh.mmd.model.AtomSet;
import com.mkulesh.mmd.model.Constants.EnergyNormType;
import com.mkulesh.mmd.model.Constants.PotentialType;
Expand Down Expand Up @@ -79,11 +80,11 @@ public Experiment[] newArray(int size)
/**
* Options class for this experiment
*/
static class Options
public static class Options
{
boolean enablePause = false;
boolean enableInfoPanel = false;
boolean drawBackground = false;
public boolean enablePause = false;
public boolean enableInfoPanel = false;
public boolean drawBackground = false;
}

/**
Expand All @@ -108,7 +109,7 @@ public Experiment(Context context)
/**
* Initialization method
*/
void initialize(Context context, SurfaceHolder holder, Options opt)
public void initialize(Context context, SurfaceHolder holder, Options opt)
{
this.context = context;
painter = new AtomPainter(context, holder);
Expand All @@ -123,7 +124,7 @@ void initialize(Context context, SurfaceHolder holder, Options opt)
updateBackgroundMode(opt.drawBackground);
}

void updateBackgroundMode(boolean drawBackground)
public void updateBackgroundMode(boolean drawBackground)
{
if (painter != null && drawBackground)
{
Expand All @@ -134,23 +135,23 @@ void updateBackgroundMode(boolean drawBackground)
/**
* Procedure sets a pause for calculation thread
*/
void pause()
public void pause()
{
threadControl.pause();
}

/**
* Procedure resumes a pause from calculation thread
*/
void resumePause(boolean resumeAll)
public void resumePause(boolean resumeAll)
{
threadControl.resume(resumeAll);
}

/**
* Procedure starts calculation and painting thread
*/
void resume()
public void resume()
{
painter.resume();
synchronized (atomSet)
Expand Down Expand Up @@ -229,7 +230,7 @@ public void run()
/**
* Procedure reads the atom parameters from shared preferences
*/
void readParameters(Context context)
public void readParameters(Context context)
{
threadControl.pause();
synchronized (atomSet)
Expand Down Expand Up @@ -276,7 +277,7 @@ void writeToBundle(Bundle outState)
/**
* Procedure performs rotation due to screen orientation change
*/
void processRotationChange(int previousRotation, int currentRotation)
public void processRotationChange(int previousRotation, int currentRotation)
{
if (previousRotation < 0 || previousRotation == currentRotation)
{
Expand Down Expand Up @@ -406,7 +407,7 @@ void setScaling(double scaleFactor, double dx, double dy)
/**
* Process change of wallpaper offset if app is running as MMDWallpaperEngine
*/
void wallpaperOffsetsChanged(float xOffset, float yOffset)
public void wallpaperOffsetsChanged(float xOffset, float yOffset)
{
if (painter != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Public License along with this program.
*/

package com.mkulesh.mmd;
package com.mkulesh.mmd.fragments;

import android.content.Intent;
import android.graphics.PixelFormat;
Expand All @@ -26,6 +26,7 @@
import android.view.View;
import android.view.ViewGroup;

import com.mkulesh.mmd.R;
import com.mkulesh.mmd.config.SettingsActivity;
import com.mkulesh.mmd.model.Constants.PotentialType;
import com.mkulesh.mmd.utils.ViewUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Public License along with this program.
*/

package com.mkulesh.mmd;
package com.mkulesh.mmd.fragments;

import android.content.SharedPreferences;
import android.os.Bundle;
Expand All @@ -24,6 +24,7 @@
import android.view.ViewGroup;
import android.widget.TextView;

import com.mkulesh.mmd.R;
import com.mkulesh.mmd.config.SettingsActivity;
import com.mkulesh.mmd.model.Constants.PotentialType;
import com.mkulesh.mmd.model.PhysicalArea;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Public License along with this program.
*/

package com.mkulesh.mmd;
package com.mkulesh.mmd.fragments;

import android.graphics.RectF;
import android.view.Gravity;
Expand All @@ -23,6 +23,7 @@
import android.view.View.OnTouchListener;
import android.view.ViewGroup;

import com.mkulesh.mmd.R;
import com.mkulesh.mmd.utils.ViewUtils;
import com.mkulesh.mmd.widgets.ControlDialog;
import com.mkulesh.mmd.widgets.DialogChangeListener;
Expand Down
13 changes: 6 additions & 7 deletions app/src/main/res/layout-land/fragment_potential.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mmd="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/aluminium_texture"
Expand All @@ -24,7 +23,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainFragmentPotential">
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<TextView
android:id="@+id/activity_potential_name"
Expand All @@ -44,17 +43,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
mmd:domainName="@string/potential_domain_name"
mmd:valueName="@string/potential_value_name" />
app:domainName="@string/potential_domain_name"
app:valueName="@string/potential_value_name" />

<com.mkulesh.mmd.widgets.PotentialView
android:id="@+id/activity_potential_derivative"
style="@style/PotentialViewStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
mmd:domainName="@string/potential_domain_name"
mmd:valueName="@string/potential_derivative_name" />
app:domainName="@string/potential_domain_name"
app:valueName="@string/potential_derivative_name" />
</LinearLayout>

</LinearLayout>

0 comments on commit d80f761

Please sign in to comment.