From e7a75f9939fd840fe1c1b6c8e0999878be09cb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=A4nge?= Date: Tue, 23 Jan 2024 14:46:52 +0100 Subject: [PATCH] Reformat code automatic code reformat using Android Studio --- app/src/main/AndroidManifest.xml | 9 +- .../activities/AboutActivity.java | 13 +- .../activities/Element.java | 193 +++--- .../activities/GameActivity.java | 614 ++++++++---------- .../activities/HelpActivity.java | 2 +- .../activities/MainActivity.java | 142 ++-- .../activities/SettingsActivity.java | 1 - .../activities/SplashActivity.java | 3 +- .../activities/StatsActivity.java | 78 ++- .../activities/TutorialActivity.java | 24 +- .../adapter/HelpExpandableListAdapter.java | 164 ++--- .../helper/AppCompatPreferenceActivity.java | 7 +- .../activities/helper/BaseActivity.java | 39 +- .../helper/BaseActivityWithoutNavBar.java | 13 +- .../activities/helper/GameState.java | 77 +-- .../activities/helper/GameStatistics.java | 36 +- .../activities/helper/Gestures.java | 10 +- .../backup/BackupCreator.kt | 2 +- .../backup/BackupRestorer.kt | 6 +- .../database/DatabaseExporter.java | 10 +- .../database/PFASQLiteHelper.java | 19 +- .../database/PFASampleDataType.java | 22 +- .../helpers/FirstLaunchManager.java | 2 +- app/src/main/res/drawable/game_brick.xml | 8 +- .../ic_keyboard_arrow_left_black_24dp.xml | 10 +- .../ic_keyboard_arrow_right_black_24dp.xml | 10 +- app/src/main/res/drawable/ic_menu_help.xml | 2 +- app/src/main/res/drawable/ic_menu_home.xml | 2 +- app/src/main/res/drawable/ic_menu_info.xml | 2 +- .../main/res/drawable/ic_menu_settings.xml | 15 +- app/src/main/res/drawable/ic_menu_stat.xml | 3 +- .../main/res/drawable/ic_menu_tutorial.xml | 2 +- app/src/main/res/drawable/inactive_button.xml | 17 +- app/src/main/res/drawable/splash_screen.xml | 6 +- .../main/res/drawable/standalone_button.xml | 7 +- .../main/res/layout-land/choose_slide1.xml | 1 - .../main/res/layout-land/choose_slide2.xml | 1 - .../main/res/layout-land/choose_slide3.xml | 1 - .../main/res/layout-land/choose_slide4.xml | 1 - .../main/res/layout-land/fragment_stats1.xml | 6 +- .../main/res/layout-land/fragment_stats2.xml | 6 +- .../main/res/layout-land/fragment_stats3.xml | 6 +- .../main/res/layout-land/fragment_stats4.xml | 6 +- .../main/res/layout-land/tutorial_slide1.xml | 1 - .../main/res/layout-land/tutorial_slide2.xml | 1 - .../main/res/layout-land/tutorial_slide3.xml | 1 - .../main/res/layout-land/tutorial_slide4.xml | 1 - app/src/main/res/layout/activity_help.xml | 2 +- app/src/main/res/layout/activity_settings.xml | 5 +- app/src/main/res/layout/activity_stats.xml | 19 +- app/src/main/res/layout/activity_tutorial.xml | 1 - app/src/main/res/layout/choose_slide1.xml | 1 - app/src/main/res/layout/choose_slide2.xml | 1 - app/src/main/res/layout/choose_slide3.xml | 1 - app/src/main/res/layout/choose_slide4.xml | 1 - app/src/main/res/layout/fragment_stats1.xml | 10 +- app/src/main/res/layout/fragment_stats2.xml | 10 +- app/src/main/res/layout/fragment_stats3.xml | 10 +- app/src/main/res/layout/fragment_stats4.xml | 10 +- app/src/main/res/layout/list_group.xml | 3 +- app/src/main/res/layout/list_item.xml | 4 +- app/src/main/res/layout/nav_header_main.xml | 2 +- app/src/main/res/layout/toolbar.xml | 5 +- app/src/main/res/layout/tutorial_slide1.xml | 1 - app/src/main/res/layout/tutorial_slide2.xml | 1 - app/src/main/res/layout/tutorial_slide3.xml | 1 - app/src/main/res/layout/tutorial_slide4.xml | 1 - app/src/main/res/menu/menu_stats.xml | 6 +- app/src/main/res/values-de/strings.xml | 12 +- app/src/main/res/values/colors.xml | 5 - app/src/main/res/values/drawables.xml | 2 +- app/src/main/res/values/strings.xml | 3 +- app/src/main/res/xml/pref_general.xml | 3 +- .../privacyfriendly2048/ExampleUnitTest.java | 4 +- 74 files changed, 809 insertions(+), 917 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bdb16a2..1f0e8cb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -58,9 +58,9 @@ - + + android:parentActivityName=".activities.MainActivity"> diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/AboutActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/AboutActivity.java index c046f82..ff18451 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/AboutActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/AboutActivity.java @@ -19,12 +19,13 @@ package org.secuso.privacyfriendly2048.activities; import android.os.Bundle; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; import android.text.method.LinkMovementMethod; import android.view.View; import android.widget.TextView; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; + import org.secuso.privacyfriendly2048.BuildConfig; import org.secuso.privacyfriendly2048.R; import org.secuso.privacyfriendly2048.activities.helper.BaseActivity; @@ -43,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_about); ActionBar ab = getSupportActionBar(); - if(ab != null) { + if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } @@ -55,9 +56,9 @@ protected void onCreate(Bundle savedInstanceState) { overridePendingTransition(0, 0); - ((TextView)findViewById(R.id.secusoWebsite)).setMovementMethod(LinkMovementMethod.getInstance()); - ((TextView)findViewById(R.id.githubURL)).setMovementMethod(LinkMovementMethod.getInstance()); - ((TextView)findViewById(R.id.textFieldVersionName)).setText(getString(R.string.version_number, BuildConfig.VERSION_NAME)); + ((TextView) findViewById(R.id.secusoWebsite)).setMovementMethod(LinkMovementMethod.getInstance()); + ((TextView) findViewById(R.id.githubURL)).setMovementMethod(LinkMovementMethod.getInstance()); + ((TextView) findViewById(R.id.textFieldVersionName)).setText(getString(R.string.version_number, BuildConfig.VERSION_NAME)); } //@Override diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java index 67abb60..527c2fa 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/Element.java @@ -25,9 +25,10 @@ import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; import android.preference.PreferenceManager; -import androidx.core.content.ContextCompat; import android.view.View; +import androidx.core.content.ContextCompat; + import org.secuso.privacyfriendly2048.R; /** @@ -54,14 +55,13 @@ public class Element extends androidx.appcompat.widget.AppCompatButton { int color; - public Element(Context c) - { + public Element(Context c) { super(c); context = c; setAllCaps(false); setTextSize(textSize); setBackgroundResource(R.drawable.game_brick); - if(PreferenceManager.getDefaultSharedPreferences(context).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(context).getString("pref_color", "1").equals("1")) setColor(context.getResources().getColor(R.color.button_empty)); else setColor(context.getResources().getColor(R.color.button_empty_2)); @@ -70,178 +70,174 @@ public Element(Context c) public void drawItem() { dNumber = number; - activated = (number!=0); - if(number== 0) { + activated = (number != 0); + if (number == 0) { setVisibility(View.INVISIBLE); setText(""); - } - else { + } else { setText("" + number); - if(getVisibility() != View.VISIBLE) + if (getVisibility() != View.VISIBLE) setVisibility(View.VISIBLE); } - if(PreferenceManager.getDefaultSharedPreferences(context).getString("pref_color","1").equals("1")) - { - switch (number){ + if (PreferenceManager.getDefaultSharedPreferences(context).getString("pref_color", "1").equals("1")) { + switch (number) { case 0: setColor(ContextCompat.getColor(context, R.color.button_empty)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 2: - setColor(ContextCompat.getColor(context,R.color.button2)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setColor(ContextCompat.getColor(context, R.color.button2)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 4: - setColor(ContextCompat.getColor(context,R.color.button4)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setColor(ContextCompat.getColor(context, R.color.button4)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 8: - setColor(ContextCompat.getColor(context,R.color.button8)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button8)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 16: - setColor(ContextCompat.getColor(context,R.color.button16)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button16)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 32: - setColor(ContextCompat.getColor(context,R.color.button32)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button32)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 64: - setColor(ContextCompat.getColor(context,R.color.button64)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button64)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 128: - setColor(ContextCompat.getColor(context,R.color.button128)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button128)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 256: - setColor(ContextCompat.getColor(context,R.color.button256)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button256)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 512: - setColor(ContextCompat.getColor(context,R.color.button512)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button512)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 1024: - setColor(ContextCompat.getColor(context,R.color.button1024)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button1024)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 2048: - setColor(ContextCompat.getColor(context,R.color.button2048)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button2048)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 4096: - setColor(ContextCompat.getColor(context,R.color.button4096)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setColor(ContextCompat.getColor(context, R.color.button4096)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 8192: - setColor(ContextCompat.getColor(context,R.color.button8192)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setColor(ContextCompat.getColor(context, R.color.button8192)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 16384: - setColor(ContextCompat.getColor(context,R.color.button16384)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button16384)); + setTextColor(ContextCompat.getColor(context, R.color.white)); textSize = textSize * 0.8f; setTextSize(textSize); break; case 32768: - setColor(ContextCompat.getColor(context,R.color.button32768)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button32768)); + setTextColor(ContextCompat.getColor(context, R.color.white)); textSize = textSize * 0.8f; setTextSize(textSize); break; } - } - else - { - switch (number){ + } else { + switch (number) { case 0: setColor(R.color.button_empty_2); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 2: - setColor(ContextCompat.getColor(context,R.color.button2_2)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setColor(ContextCompat.getColor(context, R.color.button2_2)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 4: - setColor(ContextCompat.getColor(context,R.color.button4_2)); - setTextColor(ContextCompat.getColor(context,R.color.black)); + setColor(ContextCompat.getColor(context, R.color.button4_2)); + setTextColor(ContextCompat.getColor(context, R.color.black)); break; case 8: - setColor(ContextCompat.getColor(context,R.color.button8_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button8_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 16: - setColor(ContextCompat.getColor(context,R.color.button16_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button16_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 32: - setColor(ContextCompat.getColor(context,R.color.button32_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button32_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 64: - setColor(ContextCompat.getColor(context,R.color.button64_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button64_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 128: - setColor(ContextCompat.getColor(context,R.color.button128_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button128_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 256: - setColor(ContextCompat.getColor(context,R.color.button256_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button256_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 512: - setColor(ContextCompat.getColor(context,R.color.button512_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button512_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 1024: - setColor(ContextCompat.getColor(context,R.color.button1024_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button1024_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 2048: - setColor(ContextCompat.getColor(context,R.color.button2048_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button2048_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 4096: - setColor(ContextCompat.getColor(context,R.color.button4096_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button4096_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 8192: - setColor(ContextCompat.getColor(context,R.color.button8192_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button8192_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); break; case 16384: - setColor(ContextCompat.getColor(context,R.color.button16384_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button16384_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); textSize = textSize * 0.8f; setTextSize(textSize); break; case 32768: - setColor(ContextCompat.getColor(context,R.color.button32768_2)); - setTextColor(ContextCompat.getColor(context,R.color.white)); + setColor(ContextCompat.getColor(context, R.color.button32768_2)); + setTextColor(ContextCompat.getColor(context, R.color.white)); textSize = textSize * 0.8f; setTextSize(textSize); break; } } } - private void setColor(int c) - { + + private void setColor(int c) { color = c; Drawable background = getBackground(); if (background instanceof ShapeDrawable) { - ((ShapeDrawable)background).getPaint().setColor(c); + ((ShapeDrawable) background).getPaint().setColor(c); } else if (background instanceof GradientDrawable) { - ((GradientDrawable)background).setColor(c); + ((GradientDrawable) background).setColor(c); } else if (background instanceof ColorDrawable) { - ((ColorDrawable)background).setColor(c); + ((ColorDrawable) background).setColor(c); } } - public String toString() - { + + public String toString() { return "number: " + number; } @@ -249,20 +245,24 @@ public int getNumber() { return number; } - public void setDPosition(int i, int j) - { + public void setDPosition(int i, int j) { dPosX = i; dPosY = j; } - public void setNumber(int i) - { + + public void setNumber(int i) { number = i; } - public int getdPosX(){ return dPosX;} - public int getdPosY(){ return dPosY;} + public int getdPosX() { + return dPosX; + } - public int getdNumber(){ + public int getdPosY() { + return dPosY; + } + + public int getdNumber() { return dNumber; } @@ -273,12 +273,13 @@ public int getPosX() { public int getPosY() { return posY; } - public void updateFontSize(){ - textSize=(float)(getLayoutParams().width/7.0); + + public void updateFontSize() { + textSize = (float) (getLayoutParams().width / 7.0); setTextSize(textSize); } - public Element copy() - { + + public Element copy() { Element temp = new Element(context); temp.number = number; temp.dNumber = dNumber; diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java index e182150..1e8ac16 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/GameActivity.java @@ -97,7 +97,7 @@ public static long record = 0; public static boolean moved = false; public static boolean firstTime = true; public static boolean newGame; - public boolean won2048=false; + public boolean won2048 = false; public static boolean gameOver = false; public static boolean createNewGame = true; public static boolean undo = false; @@ -120,7 +120,7 @@ public static long record = 0; @Override public boolean onPrepareOptionsMenu(Menu menu) { - MenuItem item= menu.findItem(R.id.action_settings); + MenuItem item = menu.findItem(R.id.action_settings); item.setVisible(false); super.onPrepareOptionsMenu(menu); return true; @@ -128,7 +128,7 @@ public boolean onPrepareOptionsMenu(Menu menu) { @Override public void onPause() { - Log.i("lifecycle","pause"); + Log.i("lifecycle", "pause"); save(); super.onPause(); @@ -141,7 +141,7 @@ protected void onCreate(Bundle savedInstanceState) { saveState = true; - if(savedInstanceState == null) { + if (savedInstanceState == null) { Intent intent = getIntent(); if (firstTime && intent.getBooleanExtra("new", true)) { createNewGame = true; @@ -150,9 +150,9 @@ protected void onCreate(Bundle savedInstanceState) { } sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - animationActivated = sharedPref.getBoolean("pref_animationActivated",true); + animationActivated = sharedPref.getBoolean("pref_animationActivated", true); - if(sharedPref.getBoolean("settings_display",true)) + if (sharedPref.getBoolean("settings_display", true)) getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_game); @@ -164,7 +164,7 @@ protected void onCreate(Bundle savedInstanceState) { public void initResources() { number_field = (RelativeLayout) findViewById(R.id.number_field); number_field_background = (RelativeLayout) findViewById(R.id.number_field_background); - touch_field = (RelativeLayout) findViewById(R.id.touch_field) ; + touch_field = (RelativeLayout) findViewById(R.id.touch_field); textFieldPoints = (TextView) findViewById(R.id.points); textFieldRecord = (TextView) findViewById(R.id.record); restartButton = (ImageButton) findViewById(R.id.restartButton); @@ -180,25 +180,23 @@ public void onClick(View v) { @Override public void onClick(View v) { undoButton.setVisibility(View.INVISIBLE); - if(undo&&last_elements != null) { + if (undo && last_elements != null) { gameStatistics.undo(); elements = last_elements; points = last_points; number_field.removeAllViews(); //number_field_background.removeAllViews(); points = last_points; - textFieldPoints.setText(""+points); + textFieldPoints.setText("" + points); setDPositions(false); - for(Element[] i : elements) - { - for(Element j: i) - { + for (Element[] i : elements) { + for (Element j : i) { j.setVisibility(View.INVISIBLE); number_field.addView(j); j.drawItem(); } } - for(int i = 0; i < elements.length; i++) { + for (int i = 0; i < elements.length; i++) { for (int j = 0; j < elements[i].length; j++) { elements[i][j].setOnTouchListener(swipeListener); backgroundElements[i][j].setOnTouchListener(swipeListener); @@ -223,16 +221,16 @@ public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } - public void save() - { - Log.i("saving","save"); - if(!createNewGame) + public void save() { + Log.i("saving", "save"); + if (!createNewGame) saveStateToFile(gameState); - gameStatistics.addTimePlayed(Calendar.getInstance().getTimeInMillis()-startingTime); + gameStatistics.addTimePlayed(Calendar.getInstance().getTimeInMillis() - startingTime); startingTime = Calendar.getInstance().getTimeInMillis(); saveStatisticsToFile(gameStatistics); firstTime = true; } + @Override public void onBackPressed() { save(); @@ -241,24 +239,22 @@ public void onBackPressed() { } - public void createNewGame() - { + public void createNewGame() { createNewGame = true; - getIntent().putExtra("new",true); + getIntent().putExtra("new", true); number_field.removeAllViews(); number_field_background.removeAllViews(); initialize(); } - protected void start() - { - Log.i("activity","start"); + protected void start() { + Log.i("activity", "start"); saveState = true; android.view.ViewGroup.LayoutParams lp = number_field.getLayoutParams(); //setting squared Number Field - if(number_field.getHeight()>number_field.getWidth()) + if (number_field.getHeight() > number_field.getWidth()) lp.height = number_field.getWidth(); else lp.width = number_field.getHeight(); @@ -267,21 +263,21 @@ protected void start() initialize(); setListener(); - if(newGame) { + if (newGame) { moved = true; addNumber(); } newGame = false; } - public void initializeState() - { + + public void initializeState() { points = 0; Intent intent = getIntent(); n = intent.getIntExtra("n", 4); newGame = intent.getBooleanExtra("new", true); filename = intent.getStringExtra("filename"); - undo = intent.getBooleanExtra("undo",false); + undo = intent.getBooleanExtra("undo", false); if (!newGame) { gameState = readStateFromFile(); points = gameState.points; @@ -296,23 +292,18 @@ public void initializeState() saveState = true; - } - public void drawAllElements(Element[][] e) - { - for(Element[] i : e) - { - for(Element j: i) - { + public void drawAllElements(Element[][] e) { + for (Element[] i : e) { + for (Element j : i) { j.drawItem(); } } } - public void updateGameState() - { - gameState = new GameState(elements,last_elements); + public void updateGameState() { + gameState = new GameState(elements, last_elements); gameState.n = n; gameState.points = points; gameState.last_points = last_points; @@ -322,11 +313,9 @@ public void updateGameState() } - public void initialize() - { - Log.i("activity","initialize"); - if(getIntent().getIntExtra("n",4)!=n||createNewGame) - { + public void initialize() { + Log.i("activity", "initialize"); + if (getIntent().getIntExtra("n", 4) != n || createNewGame) { initializeState(); } @@ -336,37 +325,37 @@ record = gameStatistics.getRecord(); createNewGame = false; DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); - int abstand = (10* metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT; + int abstand = (10 * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT; numberFieldSize = number_field.getWidth(); - if(numberFieldSize>number_field.getHeight()) + if (numberFieldSize > number_field.getHeight()) numberFieldSize = number_field.getHeight(); - int number_size = (numberFieldSize-abstand)/n-abstand; + int number_size = (numberFieldSize - abstand) / n - abstand; - textFieldRecord.setText(""+record); - textFieldPoints.setText(""+points); - if(undo) + textFieldRecord.setText("" + record); + textFieldPoints.setText("" + points); + if (undo) undoButton.setVisibility(View.VISIBLE); else undoButton.setVisibility(View.INVISIBLE); number_field_background.removeAllViews(); number_field.removeAllViews(); - for(int i = 0; i < elements.length; i++) { + for (int i = 0; i < elements.length; i++) { for (int j = 0; j < elements[i].length; j++) { //background elements backgroundElements[i][j] = new Element(this); //backgroundElements[i][j].setVisibility(View.INVISIBLE); elements[i][j] = new Element(this); - elements[i][j].setNumber(gameState.getNumber(i,j)); + elements[i][j].setNumber(gameState.getNumber(i, j)); elements[i][j].drawItem(); - if(elements[i][j].getNumber() >= WINTHRESHOLD) + if (elements[i][j].getNumber() >= WINTHRESHOLD) won2048 = true; - RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(number_size ,number_size); - lp.setMarginStart(abstand+j*(number_size+abstand)); - lp.topMargin = abstand+i*(number_size+abstand); - elements[i][j].setDPosition(lp.getMarginStart(),lp.topMargin); + RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(number_size, number_size); + lp.setMarginStart(abstand + j * (number_size + abstand)); + lp.topMargin = abstand + i * (number_size + abstand); + elements[i][j].setDPosition(lp.getMarginStart(), lp.topMargin); elements[i][j].setLayoutParams(lp); backgroundElements[i][j].setLayoutParams(lp); elements[i][j].updateFontSize(); @@ -377,17 +366,15 @@ record = gameStatistics.getRecord(); number_field.addView(elements[i][j]); } } - last_elements =deepCopy(elements); - if(undo) - { - for(int i = 0; i < elements.length; i++) { + last_elements = deepCopy(elements); + if (undo) { + for (int i = 0; i < elements.length; i++) { for (int j = 0; j < elements[i].length; j++) { - last_elements[i][j].setNumber(gameState.getLastNumber(i,j)); + last_elements[i][j].setNumber(gameState.getLastNumber(i, j)); } } } - if(newGame) - { + if (newGame) { moved = true; addNumber(); moved = true; @@ -395,69 +382,60 @@ record = gameStatistics.getRecord(); newGame = false; } } - public void switchElementPositions(Element e1, Element e2) - { + + public void switchElementPositions(Element e1, Element e2) { int i = e1.getdPosX(); int j = e1.getdPosY(); e1.animateMoving = true; - e1.setDPosition(e2.getdPosX(),e2.getdPosY()); + e1.setDPosition(e2.getdPosX(), e2.getdPosY()); e2.animateMoving = false; - e2.setDPosition(i,j); + e2.setDPosition(i, j); } - public Element[][] deepCopy(Element[][]e) - { + public Element[][] deepCopy(Element[][] e) { Element[][] r = new Element[e.length][]; - for(int i = 0; i < r.length; i++) - { + for (int i = 0; i < r.length; i++) { r[i] = new Element[e[i].length]; - for(int j = 0; j < r[i].length; j++) - { + for (int j = 0; j < r[i].length; j++) { r[i][j] = e[i][j].copy(); } } return r; } - public void setListener() - { - swipeListener = new Gestures(this){ + public void setListener() { + swipeListener = new Gestures(this) { public boolean onSwipeTop() { Element[][] temp = deepCopy(elements); int temp_points = points; moved = false; Element s = new Element(getApplicationContext()); - for(int i = 0; i < elements.length; i++) - { - s.number = elements[0][i].number; + for (int i = 0; i < elements.length; i++) { + s.number = elements[0][i].number; s.posX = 0; s.posY = i; - for(int j = 1; j< elements[i].length; j++) - { - if(elements[j][i].number != 0 &&( s.number == 0 || s.number == elements[j][i].number)) - { - moved=true; + for (int j = 1; j < elements[i].length; j++) { + if (elements[j][i].number != 0 && (s.number == 0 || s.number == elements[j][i].number)) { + moved = true; elements[j][i].setNumber(s.number + elements[j][i].number); elements[s.posX][s.posY].setNumber(0); switchElementPositions(elements[j][i], elements[s.posX][s.posY]); Element z = elements[j][i]; elements[j][i] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number!=0) + if (s.number != 0) points += elements[s.posX][s.posY].number; - if(s.number !=0) + if (s.number != 0) s.posX++; - j=s.posX; + j = s.posX; s.number = elements[j][i].number; - } - else if(elements[j][i].number != 0) - { + } else if (elements[j][i].number != 0) { s.number = elements[j][i].number; s.posX = j; s.posY = i; @@ -465,32 +443,27 @@ else if(elements[j][i].number != 0) } } - for(int i = 0; i < elements.length; i++) - { - s.number = elements[0][i].number; + for (int i = 0; i < elements.length; i++) { + s.number = elements[0][i].number; s.posX = 0; s.posY = i; - for(int j = 1; j< elements[i].length; j++) - { - if(elements[j][i].number != 0 && s.number == 0) - { - moved=true; + for (int j = 1; j < elements[i].length; j++) { + if (elements[j][i].number != 0 && s.number == 0) { + moved = true; elements[j][i].setNumber(s.number + elements[j][i].number); elements[s.posX][s.posY].setNumber(0); switchElementPositions(elements[j][i], elements[s.posX][s.posY]); Element z = elements[j][i]; elements[j][i] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number !=0) + if (s.number != 0) s.posX++; - j=s.posX; + j = s.posX; s.number = elements[j][i].number; - } - else if(s.number != 0) - { + } else if (s.number != 0) { s.number = elements[j][i].number; s.posX = j; s.posY = i; @@ -498,14 +471,14 @@ else if(s.number != 0) } } - if(moved) { + if (moved) { gameStatistics.addMoves(1); last_points = temp_points; last_elements = temp; undoButton.setVisibility(View.VISIBLE); undo = true; } - if(moved) + if (moved) gameStatistics.moveT(); addNumber(); setDPositions(animationActivated); @@ -513,23 +486,21 @@ else if(s.number != 0) //es wurde nach oben gewischt, hier den Code einfügen return false; } + public boolean onSwipeRight() { Element[][] temp = deepCopy(elements); int temp_points = points; moved = false; Element s = new Element(getApplicationContext()); - for(int i = 0; i < elements.length; i++) - { - s.number = elements[i][elements[i].length-1].number; + for (int i = 0; i < elements.length; i++) { + s.number = elements[i][elements[i].length - 1].number; s.posX = i; - s.posY = elements[i].length-1; + s.posY = elements[i].length - 1; - for(int j = elements[i].length-2; j >= 0; j--) - { - if(elements[i][j].number != 0 &&( s.number == 0 || s.number == elements[i][j].number)) - { - moved=true; + for (int j = elements[i].length - 2; j >= 0; j--) { + if (elements[i][j].number != 0 && (s.number == 0 || s.number == elements[i][j].number)) { + moved = true; elements[i][j].setNumber(s.number + elements[i][j].number); elements[s.posX][s.posY].setNumber(0); @@ -538,15 +509,13 @@ public boolean onSwipeRight() { elements[i][j] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number!=0) + if (s.number != 0) points += elements[s.posX][s.posY].number; - if(s.number !=0) + if (s.number != 0) s.posY--; - j=s.posY; + j = s.posY; s.number = elements[i][j].number; - } - else if(elements[i][j].number != 0) - { + } else if (elements[i][j].number != 0) { s.number = elements[i][j].number; s.posX = i; s.posY = j; @@ -554,18 +523,15 @@ else if(elements[i][j].number != 0) } } - for(int i = 0; i < elements.length; i++) - { - s.number = elements[i][elements[i].length-1].number; + for (int i = 0; i < elements.length; i++) { + s.number = elements[i][elements[i].length - 1].number; s.posX = i; - s.posY = elements[i].length-1; + s.posY = elements[i].length - 1; - for(int j = elements[i].length-2; j >= 0; j--) - { - if(elements[i][j].number != 0 && s.number == 0 ) - { - moved=true; + for (int j = elements[i].length - 2; j >= 0; j--) { + if (elements[i][j].number != 0 && s.number == 0) { + moved = true; elements[i][j].setNumber(s.number + elements[i][j].number); elements[s.posX][s.posY].setNumber(0); @@ -575,13 +541,11 @@ else if(elements[i][j].number != 0) elements[s.posX][s.posY] = z; - if(s.number !=0) + if (s.number != 0) s.posY--; - j=s.posY; + j = s.posY; s.number = elements[i][j].number; - } - else if(s.number != 0) - { + } else if (s.number != 0) { s.number = elements[i][j].number; s.posX = i; s.posY = j; @@ -589,14 +553,14 @@ else if(s.number != 0) } } - if(moved) { + if (moved) { gameStatistics.addMoves(1); last_points = temp_points; last_elements = temp; undoButton.setVisibility(View.VISIBLE); undo = true; } - if(moved) + if (moved) gameStatistics.moveR(); addNumber(); setDPositions(animationActivated); @@ -605,23 +569,21 @@ else if(s.number != 0) //es wurde nach rechts gewischt, hier den Code einfügen return false; } + public boolean onSwipeLeft() { Element[][] temp = deepCopy(elements); int temp_points = points; moved = false; Element s = new Element(getApplicationContext()); - for(int i = 0; i < elements.length; i++) - { - s.number = elements[i][0].number; + for (int i = 0; i < elements.length; i++) { + s.number = elements[i][0].number; s.posX = i; s.posY = 0; - for(int j = 1; j< elements[i].length; j++) - { - if(elements[i][j].number != 0 &&( s.number == 0 || s.number == elements[i][j].number)) - { - moved=true; + for (int j = 1; j < elements[i].length; j++) { + if (elements[i][j].number != 0 && (s.number == 0 || s.number == elements[i][j].number)) { + moved = true; elements[i][j].setNumber(s.number + elements[i][j].number); @@ -631,15 +593,13 @@ public boolean onSwipeLeft() { elements[i][j] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number!=0) + if (s.number != 0) points += elements[s.posX][s.posY].number; - if(s.number !=0) + if (s.number != 0) s.posY++; - j=s.posY; + j = s.posY; s.number = elements[i][j].number; - } - else if(elements[i][j].number != 0) - { + } else if (elements[i][j].number != 0) { s.number = elements[i][j].number; s.posX = i; s.posY = j; @@ -647,17 +607,14 @@ else if(elements[i][j].number != 0) } } - for(int i = 0; i < elements.length; i++) - { - s.number = elements[i][0].number; + for (int i = 0; i < elements.length; i++) { + s.number = elements[i][0].number; s.posX = i; s.posY = 0; - for(int j = 1; j< elements[i].length; j++) - { - if(elements[i][j].number != 0 && s.number == 0) - { - moved=true; + for (int j = 1; j < elements[i].length; j++) { + if (elements[i][j].number != 0 && s.number == 0) { + moved = true; elements[i][j].setNumber(s.number + elements[i][j].number); elements[s.posX][s.posY].setNumber(0); @@ -666,13 +623,11 @@ else if(elements[i][j].number != 0) elements[i][j] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number !=0) + if (s.number != 0) s.posY++; - j=s.posY; + j = s.posY; s.number = elements[i][j].number; - } - else if(s.number != 0) - { + } else if (s.number != 0) { s.number = elements[i][j].number; s.posX = i; s.posY = j; @@ -680,14 +635,14 @@ else if(s.number != 0) } } - if(moved) { + if (moved) { gameStatistics.addMoves(1); last_points = temp_points; last_elements = temp; undoButton.setVisibility(View.VISIBLE); undo = true; } - if(moved) + if (moved) gameStatistics.moveL(); addNumber(); setDPositions(animationActivated); @@ -695,23 +650,21 @@ else if(s.number != 0) //es wurde nach links gewischt, hier den Code einfügen return false; } + public boolean onSwipeBottom() { Element[][] temp = deepCopy(elements); int temp_points = points; moved = false; Element s = new Element(getApplicationContext()); - for(int i = 0; i < elements.length; i++) - { - s.number = elements[elements[i].length-1][i].number; - s.posX = elements[i].length-1; + for (int i = 0; i < elements.length; i++) { + s.number = elements[elements[i].length - 1][i].number; + s.posX = elements[i].length - 1; s.posY = i; - for(int j = elements[i].length-2; j>=0; j--) - { - if(elements[j][i].number != 0 &&( s.number == 0 || s.number == elements[j][i].number)) - { - moved=true; + for (int j = elements[i].length - 2; j >= 0; j--) { + if (elements[j][i].number != 0 && (s.number == 0 || s.number == elements[j][i].number)) { + moved = true; elements[j][i].setNumber(s.number + elements[j][i].number); elements[s.posX][s.posY].setNumber(0); @@ -720,15 +673,13 @@ public boolean onSwipeBottom() { elements[j][i] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number!=0) + if (s.number != 0) points += elements[s.posX][s.posY].number; - if(s.number !=0) + if (s.number != 0) s.posX--; - j=s.posX; + j = s.posX; s.number = elements[j][i].number; - } - else if(elements[j][i].number != 0) - { + } else if (elements[j][i].number != 0) { s.number = elements[j][i].number; s.posX = j; s.posY = i; @@ -736,18 +687,15 @@ else if(elements[j][i].number != 0) } } - for(int i = 0; i < elements.length; i++) - { - s.number = elements[elements[i].length-1][i].number; - s.posX = elements[i].length-1; + for (int i = 0; i < elements.length; i++) { + s.number = elements[elements[i].length - 1][i].number; + s.posX = elements[i].length - 1; s.posY = i; - for(int j = elements[i].length-2; j>=0; j--) - { - if(elements[j][i].number != 0 &&s.number == 0) - { - moved=true; + for (int j = elements[i].length - 2; j >= 0; j--) { + if (elements[j][i].number != 0 && s.number == 0) { + moved = true; elements[j][i].setNumber(s.number + elements[j][i].number); elements[s.posX][s.posY].setNumber(0); @@ -756,13 +704,11 @@ else if(elements[j][i].number != 0) elements[j][i] = elements[s.posX][s.posY]; elements[s.posX][s.posY] = z; - if(s.number !=0) + if (s.number != 0) s.posX--; - j=s.posX; + j = s.posX; s.number = elements[j][i].number; - } - else if(s.number != 0) - { + } else if (s.number != 0) { s.number = elements[j][i].number; s.posX = j; s.posY = i; @@ -770,14 +716,14 @@ else if(s.number != 0) } } - if(moved) { + if (moved) { gameStatistics.addMoves(1); last_points = temp_points; last_elements = temp; undoButton.setVisibility(View.VISIBLE); undo = true; } - if(moved) + if (moved) gameStatistics.moveD(); addNumber(); setDPositions(animationActivated); @@ -785,47 +731,42 @@ else if(s.number != 0) //es wurde nach unten gewischt, hier den Code einfügen return false; } - public boolean nichts(){ + + public boolean nichts() { //es wurde keine wischrichtung erkannt, hier den Code einfügen return false; } }; touch_field.setOnTouchListener(swipeListener); number_field.setOnTouchListener(swipeListener); - for(int i = 0; i < elements.length; i++) { + for (int i = 0; i < elements.length; i++) { for (int j = 0; j < elements[i].length; j++) { elements[i][j].setOnTouchListener(swipeListener); backgroundElements[i][j].setOnTouchListener(swipeListener); } } } - public String display(Element[][] e) - { + + public String display(Element[][] e) { String result = "\n"; - for(int i = 0; i < e.length; i++) - { - for(int j = 0; j < e[i].length;j++) + for (int i = 0; i < e.length; i++) { + for (int j = 0; j < e[i].length; j++) result = result + " " + elements[i][j].number; //+ " "+elements[i][j]; result = result + "\n"; } result += "\n"; - for(int i = 0; i < e.length; i++) - { - for(int j = 0; j < e[i].length;j++) + for (int i = 0; i < e.length; i++) { + for (int j = 0; j < e[i].length; j++) result = result + " (" + elements[i][j].getX() + " , " + elements[i][j].getY() + ")" + " v:" + elements[i][j].getVisibility();//+" "+elements[i][j]; result = result + "\n"; } return result; } - public void updateHighestNumber() - { - for(int i = 0; i < elements.length; i++) - { - for(int j = 0; j < elements[i].length; j++) - { - if(highestNumber < elements[i][j].number) - { + public void updateHighestNumber() { + for (int i = 0; i < elements.length; i++) { + for (int j = 0; j < elements[i].length; j++) { + if (highestNumber < elements[i][j].number) { highestNumber = elements[i][j].number; gameStatistics.setHighestNumber(highestNumber); } @@ -833,104 +774,86 @@ public void updateHighestNumber() } } - public void check2048() - { - if(won2048 == false) { - for(int i = 0; i < elements.length; i++) - { - for(int j = 0; j < elements[i].length; j++) - { - if(elements[i][j].number==WINTHRESHOLD) - { - - saveStatisticsToFile(gameStatistics); - //MESSAGE - new AlertDialog.Builder(this) - .setTitle((this.getResources().getString(R.string.Titel_V_Message))) - .setMessage((this.getResources().getString(R.string.Winning_Message))) - .setNegativeButton((this.getResources().getString(R.string.No_Message)), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - onBackPressed(); - - } - }) - .setPositiveButton((this.getResources().getString(R.string.Yes_Message)), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - } - }) - .setCancelable(false) - .create().show(); - won2048=true; + public void check2048() { + if (won2048 == false) { + for (int i = 0; i < elements.length; i++) { + for (int j = 0; j < elements[i].length; j++) { + if (elements[i][j].number == WINTHRESHOLD) { + + saveStatisticsToFile(gameStatistics); + //MESSAGE + new AlertDialog.Builder(this) + .setTitle((this.getResources().getString(R.string.Titel_V_Message))) + .setMessage((this.getResources().getString(R.string.Winning_Message))) + .setNegativeButton((this.getResources().getString(R.string.No_Message)), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + onBackPressed(); + + } + }) + .setPositiveButton((this.getResources().getString(R.string.Yes_Message)), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }) + .setCancelable(false) + .create().show(); + won2048 = true; + } } } } - } } - - public void setDPositions(boolean animation) - { + public void setDPositions(boolean animation) { long SCALINGSPEED = GameActivity.SCALINGSPEED; long ADDINGSPEED = GameActivity.ADDINGSPEED; long MOVINGSPEED = GameActivity.MOVINGSPEED; boolean scale = true; - if(!animation) - { + if (!animation) { SCALINGSPEED = 1; ADDINGSPEED = 1; MOVINGSPEED = 1; scale = false; } - for(Element[] i: elements) - { - for(Element j:i) - { - if(j.dPosX != j.getX()) - { - if(j.animateMoving&&animation) - { - if(j.number != j.dNumber) - j.animate().x(j.dPosX).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j,scale)).start(); + for (Element[] i : elements) { + for (Element j : i) { + if (j.dPosX != j.getX()) { + if (j.animateMoving && animation) { + if (j.number != j.dNumber) + j.animate().x(j.dPosX).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j, scale)).start(); else - j.animate().x(j.dPosX).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j,false)).start(); + j.animate().x(j.dPosX).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j, false)).start(); - } - else { - if(!animation) { + } else { + if (!animation) { ViewGroup.MarginLayoutParams lp1 = (ViewGroup.MarginLayoutParams) j.getLayoutParams(); lp1.leftMargin = j.dPosX; j.setLayoutParams(lp1); j.drawItem(); - } - else - j.animate().x(j.dPosX).setDuration(0).setStartDelay(MOVINGSPEED).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j,false)).start(); + } else + j.animate().x(j.dPosX).setDuration(0).setStartDelay(MOVINGSPEED).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j, false)).start(); } } - if(j.dPosY != j.getY()) - { - if(j.animateMoving&&animation) - { - if(j.number != j.dNumber) - j.animate().y(j.dPosY).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j,scale)).start(); + if (j.dPosY != j.getY()) { + if (j.animateMoving && animation) { + if (j.number != j.dNumber) + j.animate().y(j.dPosY).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j, scale)).start(); else - j.animate().y(j.dPosY).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j,false)).start(); + j.animate().y(j.dPosY).setDuration(MOVINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j, false)).start(); - } - else { - if(!animation) - { + } else { + if (!animation) { ViewGroup.MarginLayoutParams lp1 = (ViewGroup.MarginLayoutParams) j.getLayoutParams(); lp1.topMargin = j.dPosY; j.setLayoutParams(lp1); j.drawItem(); - } - else - j.animate().y(j.dPosY).setDuration(0).setStartDelay(MOVINGSPEED).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j,false)).start(); + } else + j.animate().y(j.dPosY).setDuration(0).setStartDelay(MOVINGSPEED).setInterpolator(new LinearInterpolator()).setListener(new MovingListener(j, false)).start(); } @@ -944,32 +867,35 @@ class MovingListener extends AnimatorListenerAdapter { Element e = null; long SCALINGSPEED = 100; float scalingFactor = 1.5f; - boolean scale =false; - public MovingListener(Element e, boolean scale ) - { + boolean scale = false; + + public MovingListener(Element e, boolean scale) { super(); this.e = e; this.SCALINGSPEED = GameActivity.SCALINGSPEED; this.scalingFactor = GameActivity.SCALINGFACTOR; this.scale = scale; } + @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); animation.setupEndValues(); - if(e!=null) + if (e != null) e.drawItem(); } + @Override - public void onAnimationPause(Animator animation){ + public void onAnimationPause(Animator animation) { super.onAnimationPause(animation); } + @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - if(e!=null) { + if (e != null) { e.drawItem(); - if(scale) + if (scale) e.animate().scaleX(scalingFactor).scaleY(scalingFactor).setDuration(SCALINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new ScalingListener(e)).start(); } @@ -978,28 +904,31 @@ public void onAnimationEnd(Animator animation) { class ScalingListener extends AnimatorListenerAdapter { Element e = null; - public ScalingListener(Element e) - { + + public ScalingListener(Element e) { super(); this.e = e; } - public ScalingListener() - { + + public ScalingListener() { super(); } + @Override public void onAnimationCancel(Animator animation) { super.onAnimationCancel(animation); animation.setupEndValues(); } + @Override - public void onAnimationPause(Animator animation){ + public void onAnimationPause(Animator animation) { super.onAnimationPause(animation); } + @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); - if(e!=null) { + if (e != null) { e.animate().scaleX(1.0f).scaleY(1.0f).setDuration(SCALINGSPEED).setStartDelay(0).setInterpolator(new LinearInterpolator()).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { @@ -1011,15 +940,14 @@ public void onAnimationCancel(Animator animation) { } } - public void addNumber() - { + public void addNumber() { - if(points>record) { + if (points > record) { record = points; gameStatistics.setRecord(record); - textFieldRecord.setText(""+record); + textFieldRecord.setText("" + record); } - if(moved) { + if (moved) { gameOver = false; moved = false; textFieldPoints.setText("" + points); @@ -1032,7 +960,7 @@ record = points; } } } - if(counter>0) { + if (counter > 0) { int index = (int) (Math.random() * counter); int number = 2; if (Math.random() > PROPABILITYFORTWO) @@ -1040,16 +968,15 @@ record = points; empty_fields[index].setNumber(number); empty_fields[index].drawItem(); - if(animationActivated){ + if (animationActivated) { empty_fields[index].setAlpha(0); empty_fields[index].animate().alpha(1).setInterpolator(new LinearInterpolator()).setStartDelay(MOVINGSPEED).setDuration(ADDINGSPEED).start(); } - if(counter == 1) - { + if (counter == 1) { gameOver = true; for (int i = 0; i < elements.length; i++) { for (int j = 0; j < elements[i].length; j++) { - if ((i+1 < elements.length && elements[i][j].number == elements[i+1][j].number)|| (j+1 < elements[i].length && elements[i][j].number == elements[i][j+1].number)) { + if ((i + 1 < elements.length && elements[i][j].number == elements[i + 1][j].number) || (j + 1 < elements[i].length && elements[i][j].number == elements[i][j + 1].number)) { gameOver = false; } } @@ -1058,16 +985,15 @@ record = points; } updateGameState(); - if(gameOver) - { + if (gameOver) { gameOver(); } } - Log.i("number of elements", ""+number_field.getChildCount() + ", "+ number_field_background.getChildCount()); + Log.i("number of elements", "" + number_field.getChildCount() + ", " + number_field_background.getChildCount()); } - public void gameOver() - { - Log.i("record",""+record + ", " + gameStatistics.getRecord()); + + public void gameOver() { + Log.i("record", "" + record + ", " + gameStatistics.getRecord()); saveStatisticsToFile(gameStatistics); new AlertDialog.Builder(this) .setTitle((this.getResources().getString(R.string.Titel_L_Message, points))) @@ -1076,7 +1002,7 @@ public void gameOver() @Override public void onClick(DialogInterface dialog, int which) { createNewGame = true; - getIntent().putExtra("new",true); + getIntent().putExtra("new", true); initialize(); deleteStateFile(); saveState = false; @@ -1092,7 +1018,7 @@ public void onClick(DialogInterface dialog, int which) { }) .setCancelable(false) .create().show(); - Log.i("record","danach"); + Log.i("record", "danach"); } @Override @@ -1113,8 +1039,7 @@ public boolean onOptionsItemSelected(MenuItem item) { if (id == R.id.action_settings) { return true; - } - else if( id == android.R.id.home){ + } else if (id == android.R.id.home) { save(); } @@ -1129,17 +1054,17 @@ public void onWindowFocusChanged(boolean hasFocus) { } + @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); - save(); + save(); } - public void saveStateToFile(GameState nS) - { - if(saveState) { + public void saveStateToFile(GameState nS) { + if (saveState) { try { if (filename == null) filename = "state" + n + ".txt"; @@ -1155,71 +1080,62 @@ public void saveStateToFile(GameState nS) } } - public boolean deleteStateFile() - { - try{ - if(filename == null) + public boolean deleteStateFile() { + try { + if (filename == null) filename = "state" + n + ".txt"; File directory = getFilesDir(); - File f = new File(directory,filename); + File f = new File(directory, filename); return f.delete(); - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); } return false; } - public GameState readStateFromFile() - { + + public GameState readStateFromFile() { GameState nS = new GameState(n); - try{ + try { File file = new File(getFilesDir(), filename); FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(fileIn); - nS = (GameState)in.readObject(); + nS = (GameState) in.readObject(); boolean emptyField = true; - for(int i = 0; i 0) - { + for (int i = 0; i < nS.numbers.length; i++) { + if (nS.numbers[i] > 0) { emptyField = false; break; } } - if(emptyField||nS.n != n) { + if (emptyField || nS.n != n) { nS = new GameState(n); newGame = true; } in.close(); fileIn.close(); - } - catch(Exception e) - { + } catch (Exception e) { newGame = true; e.printStackTrace(); } return nS; } - public GameStatistics readStatisticsFromFile() - { + + public GameStatistics readStatisticsFromFile() { GameStatistics gS = new GameStatistics(n); - try{ + try { File file = new File(getFilesDir(), "statistics" + n + ".txt"); FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(fileIn); - gS = (GameStatistics)in.readObject(); + gS = (GameStatistics) in.readObject(); in.close(); fileIn.close(); - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); } return gS; } - public void saveStatisticsToFile(GameStatistics gS) - { + + public void saveStatisticsToFile(GameStatistics gS) { try { File file = new File(getFilesDir(), gS.getFilename()); FileOutputStream fileOut = new FileOutputStream(file); diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/HelpActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/HelpActivity.java index 91d6480..2811e0e 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/HelpActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/HelpActivity.java @@ -32,6 +32,7 @@ /** * The HelpActivity is a standard activity provided by all SECUSO apps. Here you can find some FAQs with an adequate answer. + * * @author Julian Wadephul and Saskia Jacob * @version 20180910 */ @@ -64,7 +65,6 @@ private LinkedHashMap> buildData() { expandableListDetail.put(getString(R.string.help_color), Collections.singletonList(getString(R.string.help_color_answer))); - return expandableListDetail; } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/MainActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/MainActivity.java index 44fa024..d42fc98 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/MainActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/MainActivity.java @@ -25,10 +25,6 @@ import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; -import androidx.core.app.TaskStackBuilder; -import androidx.core.content.ContextCompat; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; import android.text.Html; import android.util.Log; import android.view.LayoutInflater; @@ -42,6 +38,11 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.core.app.TaskStackBuilder; +import androidx.core.content.ContextCompat; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; + import com.bumptech.glide.Glide; import org.secuso.privacyfriendly2048.R; @@ -59,7 +60,7 @@ * @author Julian Wadephul and Saskia Jacob * @version 20180910 */ -public class MainActivity extends BaseActivity{ +public class MainActivity extends BaseActivity { private ViewPager viewPager; private MainActivity.MyViewPagerAdapter myViewPagerAdapter; @@ -84,13 +85,13 @@ public class MainActivity extends BaseActivity{ false, false }; + @Override - protected void onStart() - { + protected void onStart() { super.onStart(); - preferences = getApplicationContext().getSharedPreferences(mypref,Context.MODE_PRIVATE); - editor =preferences.edit(); - currentPage = preferences.getInt("currentPage",0); + preferences = getApplicationContext().getSharedPreferences(mypref, Context.MODE_PRIVATE); + editor = preferences.edit(); + currentPage = preferences.getInt("currentPage", 0); viewPager.setCurrentItem(currentPage); updateButtons(currentPage); updateMovingButtons(currentPage); @@ -102,7 +103,6 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); - overridePendingTransition(0, 0); // Making notification bar transparent @@ -118,17 +118,14 @@ protected void onCreate(Bundle savedInstanceState) { btnNext = (ImageButton) findViewById(R.id.btn_next); - //checking resumable File directory = getFilesDir(); - File [] files = directory.listFiles(); - - for(int i = 0; i < files.length;i++) - { - Log.i("files",files[i].getName()); - for(int j = 0; j < gameResumeable.length;j++) - { - if(files[i].getName().equals("state" + (j+4) + ".txt")) + File[] files = directory.listFiles(); + + for (int i = 0; i < files.length; i++) { + Log.i("files", files[i].getName()); + for (int j = 0; j < gameResumeable.length; j++) { + if (files[i].getName().equals("state" + (j + 4) + ".txt")) gameResumeable[j] = true; } } @@ -145,59 +142,60 @@ protected void onCreate(Bundle savedInstanceState) { viewPager.setAdapter(myViewPagerAdapter); viewPager.addOnPageChangeListener(viewPagerPageChangeListener); - btnPrev.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - int current = getItem(-1); - if (current >= 0) { - // move to next screen - viewPager.setCurrentItem(current); - } else { - } + btnPrev.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int current = getItem(-1); + if (current >= 0) { + // move to next screen + viewPager.setCurrentItem(current); + } else { } - }); - - btnNext.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - // checking for last page - // if last page home screen will be launched - int current = getItem(+1); - if (current < layouts.length) { - // move to next screen - viewPager.setCurrentItem(current); - } else { - } + } + }); + + btnNext.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // checking for last page + // if last page home screen will be launched + int current = getItem(+1); + if (current < layouts.length) { + // move to next screen + viewPager.setCurrentItem(current); + } else { } - }); + } + }); } - private void addListener(Button b1,Button b2,int n) - { + + private void addListener(Button b1, Button b2, int n) { final int temp = n; b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(MainActivity.this, GameActivity.class); - intent.putExtra("n",temp); - intent.putExtra("points",0); - intent.putExtra("new",true); - intent.putExtra("filename","state"+temp+".txt"); - intent.putExtra("undo",false); + Intent intent = new Intent(MainActivity.this, GameActivity.class); + intent.putExtra("n", temp); + intent.putExtra("points", 0); + intent.putExtra("new", true); + intent.putExtra("filename", "state" + temp + ".txt"); + intent.putExtra("undo", false); createBackStack(intent); } }); b2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(MainActivity.this, GameActivity.class); - intent.putExtra("n",temp); - intent.putExtra("new",false); - intent.putExtra("filename","state"+temp+".txt"); - intent.putExtra("undo",false); + Intent intent = new Intent(MainActivity.this, GameActivity.class); + intent.putExtra("n", temp); + intent.putExtra("new", false); + intent.putExtra("filename", "state" + temp + ".txt"); + intent.putExtra("undo", false); createBackStack(intent); } }); } + private void createBackStack(Intent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { TaskStackBuilder builder = TaskStackBuilder.create(this); @@ -208,6 +206,7 @@ private void createBackStack(Intent intent) { finish(); } } + private void addBottomDots(int currentPage) { dots = new TextView[layouts.length]; @@ -226,6 +225,7 @@ private void addBottomDots(int currentPage) { if (dots.length > 0) dots[currentPage].setTextColor(activeColor); } + private int getItem(int i) { return viewPager.getCurrentItem() + i; } @@ -237,7 +237,7 @@ private int getItem(int i) { public void onPageSelected(int position) { addBottomDots(position); currentPage = position; - editor.putInt("currentPage",currentPage); + editor.putInt("currentPage", currentPage); editor.commit(); updateButtons(position); @@ -254,8 +254,8 @@ public void onPageScrollStateChanged(int arg0) { } }; - public void updateMovingButtons(int position) - { + + public void updateMovingButtons(int position) { if (position == layouts.length - 1) { // last page. make button text to GOT IT btnNext.setVisibility(View.INVISIBLE); @@ -271,23 +271,21 @@ public void updateMovingButtons(int position) btnPrev.setVisibility(View.VISIBLE); } } - public void updateButtons (int position) - { + + public void updateButtons(int position) { Button newGameButton = MainActivity.this.findViewById(R.id.button_newGame); Button continueButton = MainActivity.this.findViewById(R.id.button_continueGame); try { - if(gameResumeable[position]) + if (gameResumeable[position]) continueButton.setBackgroundResource(R.drawable.standalone_button); else continueButton.setBackgroundResource(R.drawable.inactive_button); continueButton.setEnabled(gameResumeable[position]); - } - catch(Exception aie) - { + } catch (Exception aie) { aie.printStackTrace(); } - addListener(newGameButton,continueButton,position+4); + addListener(newGameButton, continueButton, position + 4); } /** @@ -316,32 +314,31 @@ public Object instantiateItem(ViewGroup container, int position) { View view = layoutInflater.inflate(layouts[position], container, false); container.addView(view); ImageView imageView; - switch(position) - { + switch (position) { case 0: imageView = (ImageView) findViewById(R.id.main_menu_img1); - if(PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color", "1").equals("1")) Glide.with(MainActivity.this).load(R.drawable.layout4x4_s).into(imageView); else Glide.with(MainActivity.this).load(R.drawable.layout4x4_o).into(imageView); break; case 1: imageView = (ImageView) findViewById(R.id.main_menu_img2); - if(PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color", "1").equals("1")) Glide.with(MainActivity.this).load(R.drawable.layout5x5_s).into(imageView); else Glide.with(MainActivity.this).load(R.drawable.layout5x5_o).into(imageView); break; case 2: imageView = (ImageView) findViewById(R.id.main_menu_img3); - if(PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color", "1").equals("1")) Glide.with(MainActivity.this).load(R.drawable.layout6x6_s).into(imageView); else Glide.with(MainActivity.this).load(R.drawable.layout6x6_o).into(imageView); break; case 3: imageView = (ImageView) findViewById(R.id.main_menu_img4); - if(PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(MainActivity.this).getString("pref_color", "1").equals("1")) Glide.with(MainActivity.this).load(R.drawable.layout7x7_s).into(imageView); else Glide.with(MainActivity.this).load(R.drawable.layout7x7_o).into(imageView); @@ -370,6 +367,7 @@ public void destroyItem(ViewGroup container, int position, Object object) { /** * This method connects the Activity to the menu item + * * @return ID of the menu item it belongs to */ @Override diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/SettingsActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/SettingsActivity.java index 75a74af..f443bb5 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/SettingsActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/SettingsActivity.java @@ -28,7 +28,6 @@ import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; -import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import android.preference.PreferenceManager; import android.view.MenuItem; diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/SplashActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/SplashActivity.java index 1a32253..31130e5 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/SplashActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/SplashActivity.java @@ -20,6 +20,7 @@ import android.content.Intent; import android.os.Bundle; + import androidx.appcompat.app.AppCompatActivity; import org.secuso.privacyfriendly2048.helpers.FirstLaunchManager; @@ -42,7 +43,7 @@ protected void onCreate(Bundle savedInstanceState) { FirstLaunchManager firstStartPref = new FirstLaunchManager(this); - if(firstStartPref.isFirstTimeLaunch()) { + if (firstStartPref.isFirstTimeLaunch()) { firstStartPref.initFirstTimeLaunch(); mainIntent = new Intent(this, TutorialActivity.class); } else { diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/StatsActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/StatsActivity.java index ae0946e..fe7ad8d 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/StatsActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/StatsActivity.java @@ -24,14 +24,6 @@ import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.preference.PreferenceManager; -import com.google.android.material.tabs.TabLayout; - -import androidx.fragment.app.FragmentPagerAdapter; -import androidx.fragment.app.FragmentStatePagerAdapter; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; -import androidx.appcompat.widget.Toolbar; - import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -40,10 +32,17 @@ import android.widget.ImageView; import android.widget.TextView; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.fragment.app.FragmentStatePagerAdapter; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; + import com.bumptech.glide.Glide; +import com.google.android.material.tabs.TabLayout; -import org.secuso.privacyfriendly2048.activities.helper.BaseActivity; import org.secuso.privacyfriendly2048.R; +import org.secuso.privacyfriendly2048.activities.helper.BaseActivity; import org.secuso.privacyfriendly2048.activities.helper.GameStatistics; import java.io.File; @@ -69,7 +68,7 @@ public class StatsActivity extends BaseActivity { R.layout.fragment_stats4, }; - String [] TABNAMES = {"4x4","5x5","6x6","7x7"}; + String[] TABNAMES = {"4x4", "5x5", "6x6", "7x7"}; /** * The {@link PagerAdapter} that will provide @@ -135,10 +134,10 @@ public boolean onOptionsItemSelected(MenuItem item) { // as you specify a parent activity in AndroidManifest.xml. //noinspection SimplifiableIfStatement - switch(item.getItemId()) { + switch (item.getItemId()) { case R.id.action_reset: - // SaveLoadStatistics.resetStats(this); - // mSectionsPagerAdapter.refresh(this); + // SaveLoadStatistics.resetStats(this); + // mSectionsPagerAdapter.refresh(this); resetGameStatistics(); return true; @@ -149,8 +148,9 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } - public void resetGameStatistics(){ - for(int n = 4; n <= 7; n++) { + + public void resetGameStatistics() { + for (int n = 4; n <= 7; n++) { try { File file = new File(getFilesDir(), "statistics" + n + ".txt"); file.delete(); @@ -173,6 +173,7 @@ public MyViewPagerAdapter() { public CharSequence getPageTitle(int position) { return TABNAMES[position]; } + @Override public Object instantiateItem(ViewGroup container, int position) { layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); @@ -189,8 +190,7 @@ public Object instantiateItem(ViewGroup container, int position) { TextView moves = new TextView(StatsActivity.this); TextView tpm = new TextView(StatsActivity.this); TextView rekord = new TextView(StatsActivity.this); - switch(position) - { + switch (position) { case 0: highestNumber = findViewById(R.id.highest_number1); timePlayed = findViewById(R.id.time_played1); @@ -203,7 +203,7 @@ public Object instantiateItem(ViewGroup container, int position) { tpm = findViewById(R.id.time_swipes1); rekord = findViewById(R.id.highest_score1); img = findViewById(R.id.stat_img1); - if(PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color", "1").equals("1")) Glide.with(StatsActivity.this).load(R.drawable.layout4x4_s).into(img); else Glide.with(StatsActivity.this).load(R.drawable.layout4x4_o).into(img); @@ -220,7 +220,7 @@ public Object instantiateItem(ViewGroup container, int position) { tpm = findViewById(R.id.time_swipes2); rekord = findViewById(R.id.highest_score2); img = findViewById(R.id.stat_img2); - if(PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color", "1").equals("1")) Glide.with(StatsActivity.this).load(R.drawable.layout5x5_s).into(img); else Glide.with(StatsActivity.this).load(R.drawable.layout5x5_o).into(img); @@ -237,7 +237,7 @@ public Object instantiateItem(ViewGroup container, int position) { tpm = findViewById(R.id.time_swipes3); rekord = findViewById(R.id.highest_score3); img = findViewById(R.id.stat_img3); - if(PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color", "1").equals("1")) Glide.with(StatsActivity.this).load(R.drawable.layout6x6_s).into(img); else Glide.with(StatsActivity.this).load(R.drawable.layout6x6_o).into(img); @@ -254,38 +254,38 @@ public Object instantiateItem(ViewGroup container, int position) { tpm = findViewById(R.id.time_swipes4); rekord = findViewById(R.id.highest_score4); img = findViewById(R.id.stat_img4); - if(PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(StatsActivity.this).getString("pref_color", "1").equals("1")) Glide.with(StatsActivity.this).load(R.drawable.layout7x7_s).into(img); else Glide.with(StatsActivity.this).load(R.drawable.layout7x7_o).into(img); break; } - GameStatistics gameStatistics = readStatisticsFromFile(position+4); - highestNumber.setText(""+gameStatistics.getHighestNumber()); + GameStatistics gameStatistics = readStatisticsFromFile(position + 4); + highestNumber.setText("" + gameStatistics.getHighestNumber()); timePlayed.setText(formatMillis(gameStatistics.getTimePlayed())); undo.setText("" + gameStatistics.getUndo()); moves_D.setText("" + gameStatistics.getMoves_d()); moves_R.setText("" + gameStatistics.getMoves_r()); moves_T.setText("" + gameStatistics.getMoves_t()); moves_L.setText("" + gameStatistics.getMoves_l()); - moves.setText(""+gameStatistics.getMoves()); - if(gameStatistics.getMoves()!=0) - tpm.setText(""+formatSmallMillis(gameStatistics.getTimePlayed()/gameStatistics.getMoves())); + moves.setText("" + gameStatistics.getMoves()); + if (gameStatistics.getMoves() != 0) + tpm.setText("" + formatSmallMillis(gameStatistics.getTimePlayed() / gameStatistics.getMoves())); else tpm.setText("0"); - rekord.setText(""+gameStatistics.getRecord()); - + rekord.setText("" + gameStatistics.getRecord()); return view; } + public String formatSmallMillis(long timeInMillis) { String sign = ""; if (timeInMillis < 0) { sign = "-"; timeInMillis = Math.abs(timeInMillis); } - Double seconds = new Double(((double)timeInMillis) / (double)TimeUnit.SECONDS.toMillis(1)); + Double seconds = new Double(((double) timeInMillis) / (double) TimeUnit.SECONDS.toMillis(1)); StringBuilder sb = new StringBuilder(",##0.00"); DecimalFormat df = new DecimalFormat(sb.toString()); df.setRoundingMode(RoundingMode.HALF_UP); @@ -295,13 +295,14 @@ public String formatSmallMillis(long timeInMillis) { formatted.append(" s"); return formatted.toString(); } + public String formatMillis(long timeInMillis) { String sign = ""; if (timeInMillis < 0) { sign = "-"; timeInMillis = Math.abs(timeInMillis); } - Double seconds = new Double(((double)timeInMillis) / (double)TimeUnit.HOURS.toMillis(1)); + Double seconds = new Double(((double) timeInMillis) / (double) TimeUnit.HOURS.toMillis(1)); StringBuilder sb = new StringBuilder(",##0.00"); DecimalFormat df = new DecimalFormat(sb.toString()); df.setRoundingMode(RoundingMode.HALF_UP); @@ -311,6 +312,7 @@ public String formatMillis(long timeInMillis) { formatted.append(" h"); return formatted.toString(); } + @Override public int getCount() { return layouts.length; @@ -328,24 +330,19 @@ public void destroyItem(ViewGroup container, int position, Object object) { container.removeView(view); } - public GameStatistics readStatisticsFromFile(int n) - { + public GameStatistics readStatisticsFromFile(int n) { GameStatistics gS = new GameStatistics(n); - try{ + try { File file = new File(getFilesDir(), "statistics" + n + ".txt"); FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(fileIn); - gS = (GameStatistics)in.readObject(); + gS = (GameStatistics) in.readObject(); in.close(); fileIn.close(); - } - catch(InvalidClassException ice) - { + } catch (InvalidClassException ice) { File file = new File(getFilesDir(), "statistics" + n + ".txt"); file.delete(); - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(); } return gS; @@ -353,5 +350,4 @@ public GameStatistics readStatisticsFromFile(int n) } - } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/TutorialActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/TutorialActivity.java index 17f330f..4d7dc6a 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/TutorialActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/TutorialActivity.java @@ -24,10 +24,6 @@ import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; -import androidx.core.content.ContextCompat; -import androidx.viewpager.widget.PagerAdapter; -import androidx.viewpager.widget.ViewPager; -import androidx.appcompat.app.AppCompatActivity; import android.text.Html; import android.view.LayoutInflater; import android.view.View; @@ -39,6 +35,10 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.ContextCompat; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; import com.bumptech.glide.Glide; @@ -91,7 +91,6 @@ protected void onCreate(Bundle savedInstanceState) { btnNext = (Button) findViewById(R.id.btn_next); - // adding bottom dots addBottomDots(0); @@ -106,9 +105,7 @@ protected void onCreate(Bundle savedInstanceState) { try { ImageView imageView = (ImageView) findViewById(R.id.image1); Glide.with(TutorialActivity.this).load(R.mipmap.ic_splash).into(imageView);//.into(imageView);//@mipmap/ic_splash).into(imageView); - } - catch(NullPointerException ne) - { + } catch (NullPointerException ne) { } @@ -159,7 +156,7 @@ private int getItem(int i) { } private void launchHomeScreen() { - if(firstLaunchManager.isFirstTimeLaunch()) { + if (firstLaunchManager.isFirstTimeLaunch()) { Intent intent = new Intent(TutorialActivity.this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); firstLaunchManager.setFirstTimeLaunch(false); @@ -226,29 +223,28 @@ public Object instantiateItem(ViewGroup container, int position) { View view = layoutInflater.inflate(layouts[position], container, false); container.addView(view); ImageView imageView; - switch(position) - { + switch (position) { case 0: imageView = (ImageView) findViewById(R.id.image1); Glide.with(TutorialActivity.this).load(R.mipmap.ic_splash).into(imageView); break; case 1: imageView = (ImageView) findViewById(R.id.image2); - if(PreferenceManager.getDefaultSharedPreferences(TutorialActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(TutorialActivity.this).getString("pref_color", "1").equals("1")) Glide.with(TutorialActivity.this).load(R.drawable.tutorial_move_s).into(imageView); else Glide.with(TutorialActivity.this).load(R.drawable.tutorial_move_o).into(imageView); break; case 2: imageView = (ImageView) findViewById(R.id.image3); - if(PreferenceManager.getDefaultSharedPreferences(TutorialActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(TutorialActivity.this).getString("pref_color", "1").equals("1")) Glide.with(TutorialActivity.this).load(R.drawable.tutorial_swipe_s).into(imageView); else Glide.with(TutorialActivity.this).load(R.drawable.tutorial_swipe_o).into(imageView); break; case 3: imageView = (ImageView) findViewById(R.id.image4); - if(PreferenceManager.getDefaultSharedPreferences(TutorialActivity.this).getString("pref_color","1").equals("1")) + if (PreferenceManager.getDefaultSharedPreferences(TutorialActivity.this).getString("pref_color", "1").equals("1")) Glide.with(TutorialActivity.this).load(R.drawable.tutorial_add_s).into(imageView); else Glide.with(TutorialActivity.this).load(R.drawable.tutorial_add_o).into(imageView); diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/adapter/HelpExpandableListAdapter.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/adapter/HelpExpandableListAdapter.java index 9c02190..8a4ed75 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/adapter/HelpExpandableListAdapter.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/adapter/HelpExpandableListAdapter.java @@ -40,87 +40,87 @@ public class HelpExpandableListAdapter extends BaseExpandableListAdapter { - private Context context; - private List expandableListTitle; - private HashMap> expandableListDetail; - - public HelpExpandableListAdapter(Context context, List expandableListTitle, - HashMap> expandableListDetail) { - this.context = context; - this.expandableListTitle = expandableListTitle; - this.expandableListDetail = expandableListDetail; + private Context context; + private List expandableListTitle; + private HashMap> expandableListDetail; + + public HelpExpandableListAdapter(Context context, List expandableListTitle, + HashMap> expandableListDetail) { + this.context = context; + this.expandableListTitle = expandableListTitle; + this.expandableListDetail = expandableListDetail; + } + + @Override + public Object getChild(int listPosition, int expandedListPosition) { + return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)) + .get(expandedListPosition); + } + + @Override + public long getChildId(int listPosition, int expandedListPosition) { + return expandedListPosition; + } + + @Override + public View getChildView(int listPosition, final int expandedListPosition, + boolean isLastChild, View convertView, ViewGroup parent) { + final String expandedListText = (String) getChild(listPosition, expandedListPosition); + if (convertView == null) { + LayoutInflater layoutInflater = (LayoutInflater) this.context + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = layoutInflater.inflate(R.layout.list_item, null); } - - @Override - public Object getChild(int listPosition, int expandedListPosition) { - return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)) - .get(expandedListPosition); - } - - @Override - public long getChildId(int listPosition, int expandedListPosition) { - return expandedListPosition; - } - - @Override - public View getChildView(int listPosition, final int expandedListPosition, - boolean isLastChild, View convertView, ViewGroup parent) { - final String expandedListText = (String) getChild(listPosition, expandedListPosition); - if (convertView == null) { - LayoutInflater layoutInflater = (LayoutInflater) this.context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = layoutInflater.inflate(R.layout.list_item, null); - } - TextView expandedListTextView = (TextView) convertView - .findViewById(R.id.expandedListItem); - expandedListTextView.setText(expandedListText); - return convertView; - } - - @Override - public int getChildrenCount(int listPosition) { - return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)) - .size(); - } - - @Override - public Object getGroup(int listPosition) { - return this.expandableListTitle.get(listPosition); - } - - @Override - public int getGroupCount() { - return this.expandableListTitle.size(); - } - - @Override - public long getGroupId(int listPosition) { - return listPosition; - } - - @Override - public View getGroupView(int listPosition, boolean isExpanded, - View convertView, ViewGroup parent) { - String listTitle = (String) getGroup(listPosition); - if (convertView == null) { - LayoutInflater layoutInflater = (LayoutInflater) this.context. - getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = layoutInflater.inflate(R.layout.list_group, null); - } - TextView listTitleTextView = (TextView) convertView - .findViewById(R.id.listTitle); - listTitleTextView.setTypeface(null, Typeface.BOLD); - listTitleTextView.setText(listTitle); - return convertView; - } - - @Override - public boolean hasStableIds() { - return false; - } - - @Override - public boolean isChildSelectable(int listPosition, int expandedListPosition) { - return true; + TextView expandedListTextView = (TextView) convertView + .findViewById(R.id.expandedListItem); + expandedListTextView.setText(expandedListText); + return convertView; + } + + @Override + public int getChildrenCount(int listPosition) { + return this.expandableListDetail.get(this.expandableListTitle.get(listPosition)) + .size(); + } + + @Override + public Object getGroup(int listPosition) { + return this.expandableListTitle.get(listPosition); + } + + @Override + public int getGroupCount() { + return this.expandableListTitle.size(); + } + + @Override + public long getGroupId(int listPosition) { + return listPosition; + } + + @Override + public View getGroupView(int listPosition, boolean isExpanded, + View convertView, ViewGroup parent) { + String listTitle = (String) getGroup(listPosition); + if (convertView == null) { + LayoutInflater layoutInflater = (LayoutInflater) this.context. + getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = layoutInflater.inflate(R.layout.list_group, null); } - } \ No newline at end of file + TextView listTitleTextView = (TextView) convertView + .findViewById(R.id.listTitle); + listTitleTextView.setTypeface(null, Typeface.BOLD); + listTitleTextView.setText(listTitle); + return convertView; + } + + @Override + public boolean hasStableIds() { + return false; + } + + @Override + public boolean isChildSelectable(int listPosition, int expandedListPosition) { + return true; + } +} \ No newline at end of file diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/AppCompatPreferenceActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/AppCompatPreferenceActivity.java index c3a30c6..355d99a 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/AppCompatPreferenceActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/AppCompatPreferenceActivity.java @@ -21,14 +21,15 @@ import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceActivity; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; + import androidx.annotation.LayoutRes; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.widget.Toolbar; -import android.view.MenuInflater; -import android.view.View; -import android.view.ViewGroup; /** * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivity.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivity.java index a82ac49..9170670 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivity.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivity.java @@ -25,17 +25,18 @@ import android.os.Handler; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; -import com.google.android.material.navigation.NavigationView; -import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener; -import androidx.core.app.TaskStackBuilder; -import androidx.core.view.GravityCompat; -import androidx.drawerlayout.widget.DrawerLayout; +import android.view.MenuItem; +import android.view.View; + import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.core.app.TaskStackBuilder; +import androidx.core.view.GravityCompat; +import androidx.drawerlayout.widget.DrawerLayout; -import android.view.MenuItem; -import android.view.View; +import com.google.android.material.navigation.NavigationView; +import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener; import org.secuso.privacyfriendly2048.R; import org.secuso.privacyfriendly2048.activities.AboutActivity; @@ -50,14 +51,13 @@ * @version 20171017 * This class is a parent class of all activities that can be accessed from the * Navigation Drawer (example see MainActivity.java) - * + *

* The default NavigationDrawer functionality is implemented in this class. If you wish to inherit * the default behaviour, make sure the content view has a NavigationDrawer with the id 'nav_view', * the header should point to 'nav_header_main' and the menu should be loaded from 'main_drawer'. - * + *

* Also the main layout that holds the content of the activity should have the id 'main_content'. * This way it will automatically fade in and out every time a transition is happening. - * */ public abstract class BaseActivity extends AppCompatActivity implements OnNavigationItemSelectedListener { @@ -69,7 +69,7 @@ public abstract class BaseActivity extends AppCompatActivity implements OnNaviga public static final int MAIN_CONTENT_FADEIN_DURATION = 250; // Navigation drawer: - public DrawerLayout mDrawerLayout; + public DrawerLayout mDrawerLayout; private NavigationView mNavigationView; // Helper @@ -106,10 +106,9 @@ public boolean onNavigationItemSelected(MenuItem item) { } - protected boolean goToNavigationItem(final int itemId) { - if(itemId == getNavigationDrawerID()) { + if (itemId == getNavigationDrawerID()) { // just close drawer because we are already in this activity mDrawerLayout.closeDrawer(GravityCompat.START); return true; @@ -137,7 +136,7 @@ public void run() { // set active navigation item private void selectNavigationItem(int itemId) { - for(int i = 0 ; i < mNavigationView.getMenu().size(); i++) { + for (int i = 0; i < mNavigationView.getMenu().size(); i++) { boolean b = itemId == mNavigationView.getMenu().getItem(i).getItemId(); mNavigationView.getMenu().getItem(i).setChecked(b); } @@ -146,6 +145,7 @@ private void selectNavigationItem(int itemId) { /** * Enables back navigation for activities that are launched from the NavBar. See * {@code AndroidManifest.xml} to find out the parent activity names for each activity. + * * @param intent */ private void createBackStack(Intent intent) { @@ -162,12 +162,13 @@ private void createBackStack(Intent intent) { /** * This method manages the behaviour of the navigation drawer * Add your menu items (ids) to res/menu/activity_main_drawer.xml + * * @param itemId Item that has been clicked by the user */ private void callDrawerItem(final int itemId) { Intent intent; - switch(itemId) { + switch (itemId) { case R.id.nav_example: intent = new Intent(this, MainActivity.class); @@ -187,13 +188,13 @@ private void callDrawerItem(final int itemId) { createBackStack(intent); break; case R.id.nav_statistics: - intent = new Intent(this,StatsActivity.class); + intent = new Intent(this, StatsActivity.class); createBackStack(intent); break; case R.id.nav_settings: intent = new Intent(this, SettingsActivity.class); - intent.putExtra( PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName() ); - intent.putExtra( PreferenceActivity.EXTRA_NO_HEADERS, true ); + intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.GeneralPreferenceFragment.class.getName()); + intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); createBackStack(intent); break; default: @@ -205,7 +206,7 @@ protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - if(getSupportActionBar() == null) { + if (getSupportActionBar() == null) { setSupportActionBar(toolbar); } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivityWithoutNavBar.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivityWithoutNavBar.java index 919128a..dfc144d 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivityWithoutNavBar.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/BaseActivityWithoutNavBar.java @@ -20,15 +20,9 @@ import android.os.Bundle; import android.os.Handler; +import android.view.View; -import com.google.android.material.navigation.NavigationView.OnNavigationItemSelectedListener; -import androidx.core.app.TaskStackBuilder; -import androidx.core.view.GravityCompat; -import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; - -import android.view.View; import org.secuso.privacyfriendly2048.R; @@ -37,14 +31,13 @@ * @version 20171017 * This class is a parent class of all activities that can be accessed from the * Navigation Drawer (example see MainActivity.java) - * + *

* The default NavigationDrawer functionality is implemented in this class. If you wish to inherit * the default behaviour, make sure the content view has a NavigationDrawer with the id 'nav_view', * the header should point to 'nav_header_main' and the menu should be loaded from 'main_drawer'. - * + *

* Also the main layout that holds the content of the activity should have the id 'main_content'. * This way it will automatically fade in and out every time a transition is happening. - * */ public abstract class BaseActivityWithoutNavBar extends AppCompatActivity { diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameState.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameState.java index bee8e3a..3de5a90 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameState.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameState.java @@ -20,14 +20,11 @@ package org.secuso.privacyfriendly2048.activities.helper; -import android.util.Log; - import org.secuso.privacyfriendly2048.activities.Element; import java.io.Serializable; /** - * * @author Julian Wadephul and Saskia Jacob * @version 20180807 */ @@ -37,86 +34,75 @@ public class GameState implements Serializable { public int[] last_numbers; public int points = 0; public int last_points = 0; - public boolean undo=false; + public boolean undo = false; - public GameState(int size) - { - numbers = new int[size*size]; + public GameState(int size) { + numbers = new int[size * size]; } - public GameState(int [][] e) - { + + public GameState(int[][] e) { int length = 1; - for(int i = 0; i < e.length; i++) - { - if(e[i].length > length) + for (int i = 0; i < e.length; i++) { + if (e[i].length > length) length = e[i].length; } this.n = e.length; - numbers = new int[e.length*e.length]; + numbers = new int[e.length * e.length]; int c = 0; - for(int i = 0; i < e.length;i++) - { - for(int j = 0; j < e[i].length;j++){ + for (int i = 0; i < e.length; i++) { + for (int j = 0; j < e[i].length; j++) { numbers[c++] = e[i][j]; } } last_numbers = numbers; } - public GameState(Element[][] e, Element[][] e2) - { + + public GameState(Element[][] e, Element[][] e2) { int length = 1; - for(int i = 0; i < e.length; i++) - { - if(e[i].length > length) + for (int i = 0; i < e.length; i++) { + if (e[i].length > length) length = e[i].length; } this.n = e.length; - numbers = new int[e.length*e.length]; + numbers = new int[e.length * e.length]; int c = 0; - for(int i = 0; i < e.length;i++) - { - for(int j = 0; j < e[i].length;j++){ + for (int i = 0; i < e.length; i++) { + for (int j = 0; j < e[i].length; j++) { numbers[c++] = e[i][j].number; } } length = 1; - for(int i = 0; i < e2.length; i++) - { - if(e2[i].length > length) + for (int i = 0; i < e2.length; i++) { + if (e2[i].length > length) length = e2[i].length; } - last_numbers = new int[e2.length*e2.length]; + last_numbers = new int[e2.length * e2.length]; c = 0; - for(int i = 0; i < e2.length;i++) - { - for(int j = 0; j < e2[i].length;j++){ + for (int i = 0; i < e2.length; i++) { + for (int j = 0; j < e2[i].length; j++) { last_numbers[c++] = e2[i][j].number; } } } - public int getNumber(int i, int j) - { + + public int getNumber(int i, int j) { try { - return numbers[i*n+j]; - } - catch(ArrayIndexOutOfBoundsException e) - { + return numbers[i * n + j]; + } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); } return 0; } - public int getLastNumber(int i, int j) - { + + public int getLastNumber(int i, int j) { try { - return last_numbers[i*n+j]; - } - catch(ArrayIndexOutOfBoundsException e) - { + return last_numbers[i * n + j]; + } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); } @@ -124,11 +110,10 @@ public int getLastNumber(int i, int j) } - @Override public String toString() { String result = "numbers: "; - for (int i:numbers) { + for (int i : numbers) { result += i + " "; } result += ", n: " + n; diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameStatistics.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameStatistics.java index 3347c17..84fbb43 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameStatistics.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/GameStatistics.java @@ -39,11 +39,10 @@ private long record = 0; private int undo = 0; private int moves_l = 0; private int moves_r = 0; - private int moves_t= 0; + private int moves_t = 0; private int moves_d = 0; - public GameStatistics(int n) - { + public GameStatistics(int n) { this.n = n; filename = "statistics" + n + ".txt"; } @@ -54,8 +53,8 @@ public long getHighestNumber() { } public void setHighestNumber(long highestNumber) { - if(this.highestNumber < highestNumber) - this.highestNumber = highestNumber; + if (this.highestNumber < highestNumber) + this.highestNumber = highestNumber; } public long getTimePlayed() { @@ -66,8 +65,7 @@ public void addTimePlayed(long timePlayed) { this.timePlayed += timePlayed; } - public boolean resetTimePlayed() - { + public boolean resetTimePlayed() { this.timePlayed = 0; return true; } @@ -92,36 +90,34 @@ public void setRecord(long record) { this.record = record; } - public void undo() - { + public void undo() { undo++; } - public void moveL() - { + + public void moveL() { moves_l++; } - public void moveR() - { + + public void moveR() { moves_r++; } - public void moveT() - { + + public void moveT() { moves_t++; } - public void moveD() - { + + public void moveD() { moves_d++; } - public int getUndo() - { + public int getUndo() { return undo; } @Override public String toString() { return "moves " + moves + - " timePlayed " + timePlayed/1000.0f + + " timePlayed " + timePlayed / 1000.0f + " highest Number " + highestNumber + " record" + record; } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/Gestures.java b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/Gestures.java index 10ad66e..8b9da6a 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/Gestures.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/activities/helper/Gestures.java @@ -20,13 +20,13 @@ package org.secuso.privacyfriendly2048.activities.helper; import android.content.Context; -import android.util.Log; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; /** * This class implements the Gestures Listener for swiping in the game + * * @author Julian Wadephul and Saskia Jacob * @version 20180807 */ @@ -57,7 +57,7 @@ public boolean onDown(MotionEvent e) { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - + boolean result = false; try { float diffY = e2.getY() - e1.getY(); @@ -69,7 +69,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve } else { result = onSwipeLeft(); } - }else{ + } else { result = nichts(); } } else { @@ -79,7 +79,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve } else { result = onSwipeTop(); } - }else{ + } else { result = nichts(); } } @@ -98,7 +98,7 @@ public boolean onSwipeLeft() { return false; } - public boolean nichts(){ + public boolean nichts() { return false; } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupCreator.kt b/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupCreator.kt index 8c75900..0e0bc8c 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupCreator.kt +++ b/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupCreator.kt @@ -5,11 +5,11 @@ import android.content.Context import android.preference.PreferenceManager import android.util.JsonWriter import android.util.Log +import org.secuso.privacyfriendly2048.database.PFASQLiteHelper import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil.getSupportSQLiteOpenHelper import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil.writeDatabase import org.secuso.privacyfriendlybackup.api.backup.PreferenceUtil.writePreferences import org.secuso.privacyfriendlybackup.api.pfa.IBackupCreator -import org.secuso.privacyfriendly2048.database.PFASQLiteHelper import java.io.OutputStream import java.io.OutputStreamWriter diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupRestorer.kt b/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupRestorer.kt index 88db518..7ad5098 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupRestorer.kt +++ b/app/src/main/java/org/secuso/privacyfriendly2048/backup/BackupRestorer.kt @@ -5,11 +5,10 @@ import android.content.SharedPreferences import android.preference.PreferenceManager import android.util.JsonReader import android.util.Log -import androidx.annotation.NonNull +import org.secuso.privacyfriendly2048.database.PFASQLiteHelper import org.secuso.privacyfriendlybackup.api.backup.DatabaseUtil import org.secuso.privacyfriendlybackup.api.backup.FileUtil import org.secuso.privacyfriendlybackup.api.pfa.IBackupRestorer -import org.secuso.privacyfriendly2048.database.PFASQLiteHelper import java.io.IOException import java.io.InputStream import java.io.InputStreamReader @@ -75,17 +74,20 @@ class BackupRestorer : IBackupRestorer { when (name) { "switch_preference_1", "pref_animationActivated" -> preferences.putBoolean(name, reader.nextBoolean()) + "pref_color" -> preferences.putString(name, reader.nextString()) "FirstLaunchManager.PREF_PICKER_SECONDS", "FirstLaunchManager.PREF_PICKER_MINUTES", "FirstLaunchManager.PREF_BREAK_PICKER_SECONDS", "FirstLaunchManager.PREF_PICKER_HOURS", "FirstLaunchManager.PREF_BREAK_PICKER_MINUTES" -> preferences.putInt(name, reader.nextInt()) + "pref_schedule_exercise_days" -> preferences.putStringSet(name, readPreferenceSet(reader)) "WORK_TIME", "PAUSE TIME", "pref_schedule_exercise_time", "DEFAULT_EXERCISE_SET" -> preferences.putLong(name, reader.nextLong()) + else -> throw RuntimeException("Unknown preference $name") } } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java b/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java index 26fbde8..c391038 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/database/DatabaseExporter.java @@ -31,10 +31,10 @@ /** * @author Karola Marky * @version 20161225 - * Structure based on http://tech.sarathdr.com/android-app/convert-database-cursor-result-to-json-array-android-app-development/ - * accessed at 25th December 2016 - *

- * This class turns a database into a JSON string + * Structure based on http://tech.sarathdr.com/android-app/convert-database-cursor-result-to-json-array-android-app-development/ + * accessed at 25th December 2016 + *

+ * This class turns a database into a JSON string */ public class DatabaseExporter { @@ -51,6 +51,7 @@ public DatabaseExporter(String DB_PATH, String DB_NAME) { /** * Turns a single DB table into a JSON string + * * @return JSON string of the table */ public JSONArray tableToJSON(String TABLE_NAME) { @@ -123,7 +124,6 @@ public ArrayList getTableNames() { } /** - * * @return Entire DB as JSONObject * @throws JSONException */ diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASQLiteHelper.java b/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASQLiteHelper.java index 7c028e1..8014401 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASQLiteHelper.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASQLiteHelper.java @@ -29,12 +29,11 @@ import java.util.List; /** - * * @author Karola Marky * @version 20161223 * Structure based on http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/ * accessed at 16th June 2016 - * + *

* This class defines the structure of our database. */ @@ -90,6 +89,7 @@ public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVers * Adds a single sampleData to our Table * As no ID is provided and KEY_ID is autoincremented (see line 50) * the last available key of the table is taken and incremented by 1 + * * @param sampleData data that will be added */ public void addSampleData(PFASampleDataType sampleData) { @@ -109,8 +109,9 @@ public void addSampleData(PFASampleDataType sampleData) { * Adds a single sampleData to our Table * This method can be used for re-insertion for example an undo-action * Therefore, the key of the sampleData will also be written into the database + * * @param sampleData data that will be added - * Only use this for undo options and re-insertions + * Only use this for undo options and re-insertions */ public void addSampleDataWithID(PFASampleDataType sampleData) { SQLiteDatabase database = this.getWritableDatabase(); @@ -131,6 +132,7 @@ public void addSampleDataWithID(PFASampleDataType sampleData) { /** * This method gets a single sampleData entry based on its ID + * * @param id of the sampleData that is requested, could be get by the get-method * @return the sampleData that is requested. */ @@ -145,7 +147,7 @@ public PFASampleDataType getSampleData(int id) { PFASampleDataType sampleData = new PFASampleDataType(); - if( cursor != null && cursor.moveToFirst() ){ + if (cursor != null && cursor.moveToFirst()) { sampleData.setID(Integer.parseInt(cursor.getString(0))); sampleData.setDOMAIN(cursor.getString(1)); sampleData.setUSERNAME(cursor.getString(2)); @@ -163,6 +165,7 @@ public PFASampleDataType getSampleData(int id) { /** * This method returns all data from the DB as a list * This could be used for instance to fill a recyclerView + * * @return A list of all available sampleData in the Database */ public List getAllSampleData() { @@ -194,6 +197,7 @@ public List getAllSampleData() { /** * Updates a database entry. + * * @param sampleData * @return actually makes the update */ @@ -207,18 +211,19 @@ public int updateSampleData(PFASampleDataType sampleData) { values.put(KEY_LENGTH, sampleData.getLENGTH()); return database.update(TABLE_SAMPLEDATA, values, KEY_ID + " = ?", - new String[] { String.valueOf(sampleData.getID()) }); + new String[]{String.valueOf(sampleData.getID())}); } /** * Deletes sampleData from the DB * This method takes the sampleData and extracts its key to build the delete-query + * * @param sampleData that will be deleted */ public void deleteSampleData(PFASampleDataType sampleData) { SQLiteDatabase database = this.getWritableDatabase(); database.delete(TABLE_SAMPLEDATA, KEY_ID + " = ?", - new String[] { Integer.toString(sampleData.getID()) }); + new String[]{Integer.toString(sampleData.getID())}); //always close the DB after deletion of single entries database.close(); } @@ -229,7 +234,7 @@ public void deleteSampleData(PFASampleDataType sampleData) { */ public void deleteAllSampleData() { SQLiteDatabase database = this.getWritableDatabase(); - database.execSQL("delete from "+ TABLE_SAMPLEDATA); + database.execSQL("delete from " + TABLE_SAMPLEDATA); } } diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASampleDataType.java b/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASampleDataType.java index c1b5945..4f104aa 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASampleDataType.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/database/PFASampleDataType.java @@ -19,15 +19,13 @@ package org.secuso.privacyfriendly2048.database; /** - * * @author Karola Marky * @version 20161223 - * + *

* This class holds the "data type" that will be stored in the database * Each column of the database will be a private variable in this class. * For each data type one class is required. * In our example we only use one data type, which is sampleData - * */ public class PFASampleDataType { @@ -38,22 +36,24 @@ public class PFASampleDataType { private String USERNAME; private int LENGTH; - public PFASampleDataType() { } + public PFASampleDataType() { + } /** * Always use this constructor to generate data with values. - * @param ID The primary key for the database (will be automatically set by the DB) - * @param DOMAIN Some sample String that could be in the DB + * + * @param ID The primary key for the database (will be automatically set by the DB) + * @param DOMAIN Some sample String that could be in the DB * @param USERNAME Some sample String that could be in the DB - * @param LENGTH Some sample int that could be in the DB + * @param LENGTH Some sample int that could be in the DB */ public PFASampleDataType(int ID, String DOMAIN, String USERNAME, int LENGTH) { - this.ID=ID; - this.DOMAIN=DOMAIN; - this.USERNAME=USERNAME; - this.LENGTH=LENGTH; + this.ID = ID; + this.DOMAIN = DOMAIN; + this.USERNAME = USERNAME; + this.LENGTH = LENGTH; } /** diff --git a/app/src/main/java/org/secuso/privacyfriendly2048/helpers/FirstLaunchManager.java b/app/src/main/java/org/secuso/privacyfriendly2048/helpers/FirstLaunchManager.java index aa4b221..950ac92 100644 --- a/app/src/main/java/org/secuso/privacyfriendly2048/helpers/FirstLaunchManager.java +++ b/app/src/main/java/org/secuso/privacyfriendly2048/helpers/FirstLaunchManager.java @@ -57,7 +57,7 @@ public boolean isFirstTimeLaunch() { } public void initFirstTimeLaunch() { - if(pref.getBoolean(IS_FIRST_TIME_LAUNCH, true)) { + if (pref.getBoolean(IS_FIRST_TIME_LAUNCH, true)) { // First time setup in here } } diff --git a/app/src/main/res/drawable/game_brick.xml b/app/src/main/res/drawable/game_brick.xml index 8f4ba23..29aed91 100644 --- a/app/src/main/res/drawable/game_brick.xml +++ b/app/src/main/res/drawable/game_brick.xml @@ -1,10 +1,8 @@ - + - + - + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml b/app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml index c9f7747..6385431 100644 --- a/app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml +++ b/app/src/main/res/drawable/ic_keyboard_arrow_left_black_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z" /> diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml b/app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml index a3d1622..138fcc3 100644 --- a/app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml +++ b/app/src/main/res/drawable/ic_keyboard_arrow_right_black_24dp.xml @@ -1,9 +1,9 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z" /> diff --git a/app/src/main/res/drawable/ic_menu_help.xml b/app/src/main/res/drawable/ic_menu_help.xml index 4148ec9..d09c967 100644 --- a/app/src/main/res/drawable/ic_menu_help.xml +++ b/app/src/main/res/drawable/ic_menu_help.xml @@ -5,5 +5,5 @@ android:viewportHeight="24.0"> + android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_home.xml b/app/src/main/res/drawable/ic_menu_home.xml index 5a425b4..ee65a56 100644 --- a/app/src/main/res/drawable/ic_menu_home.xml +++ b/app/src/main/res/drawable/ic_menu_home.xml @@ -5,5 +5,5 @@ android:viewportHeight="24.0"> + android:pathData="M10,20v-6h4v6h5v-8h3L12,3 2,12h3v8z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_info.xml b/app/src/main/res/drawable/ic_menu_info.xml index 2851ab6..f793eb1 100644 --- a/app/src/main/res/drawable/ic_menu_info.xml +++ b/app/src/main/res/drawable/ic_menu_info.xml @@ -5,5 +5,5 @@ android:viewportHeight="24.0"> + android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_settings.xml b/app/src/main/res/drawable/ic_menu_settings.xml index e7ba9f6..d4786a3 100644 --- a/app/src/main/res/drawable/ic_menu_settings.xml +++ b/app/src/main/res/drawable/ic_menu_settings.xml @@ -1,7 +1,10 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_menu_stat.xml b/app/src/main/res/drawable/ic_menu_stat.xml index 0e41c84..22e7a48 100644 --- a/app/src/main/res/drawable/ic_menu_stat.xml +++ b/app/src/main/res/drawable/ic_menu_stat.xml @@ -1,4 +1,3 @@ - + android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM9,17L7,17v-7h2v7zM13,17h-2L11,7h2v10zM17,17h-2v-4h2v4z" /> diff --git a/app/src/main/res/drawable/ic_menu_tutorial.xml b/app/src/main/res/drawable/ic_menu_tutorial.xml index f8d18b2..814e014 100644 --- a/app/src/main/res/drawable/ic_menu_tutorial.xml +++ b/app/src/main/res/drawable/ic_menu_tutorial.xml @@ -6,5 +6,5 @@ android:viewportHeight="24.0"> + android:pathData="M5,13.18v4L12,21l7,-3.82v-4L12,17l-7,-3.82zM12,3L1,9l11,6 9,-4.91V17h2V9L12,3z" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/inactive_button.xml b/app/src/main/res/drawable/inactive_button.xml index 523ab80..2d803c7 100644 --- a/app/src/main/res/drawable/inactive_button.xml +++ b/app/src/main/res/drawable/inactive_button.xml @@ -1,11 +1,10 @@ - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/splash_screen.xml b/app/src/main/res/drawable/splash_screen.xml index f6748aa..77f23d3 100644 --- a/app/src/main/res/drawable/splash_screen.xml +++ b/app/src/main/res/drawable/splash_screen.xml @@ -1,12 +1,10 @@ - + + android:gravity="center" /> \ No newline at end of file diff --git a/app/src/main/res/drawable/standalone_button.xml b/app/src/main/res/drawable/standalone_button.xml index 8f125d3..de7f884 100644 --- a/app/src/main/res/drawable/standalone_button.xml +++ b/app/src/main/res/drawable/standalone_button.xml @@ -1,10 +1,9 @@ - + - - + + diff --git a/app/src/main/res/layout-land/choose_slide1.xml b/app/src/main/res/layout-land/choose_slide1.xml index c0aaadb..4c1892c 100644 --- a/app/src/main/res/layout-land/choose_slide1.xml +++ b/app/src/main/res/layout-land/choose_slide1.xml @@ -1,6 +1,5 @@ + + + + diff --git a/app/src/main/res/layout-land/tutorial_slide2.xml b/app/src/main/res/layout-land/tutorial_slide2.xml index 27b462d..b823b9d 100644 --- a/app/src/main/res/layout-land/tutorial_slide2.xml +++ b/app/src/main/res/layout-land/tutorial_slide2.xml @@ -1,6 +1,5 @@ diff --git a/app/src/main/res/layout-land/tutorial_slide3.xml b/app/src/main/res/layout-land/tutorial_slide3.xml index 8efcf1a..6c44a1d 100644 --- a/app/src/main/res/layout-land/tutorial_slide3.xml +++ b/app/src/main/res/layout-land/tutorial_slide3.xml @@ -1,6 +1,5 @@ diff --git a/app/src/main/res/layout-land/tutorial_slide4.xml b/app/src/main/res/layout-land/tutorial_slide4.xml index e4d1f07..30d4577 100644 --- a/app/src/main/res/layout-land/tutorial_slide4.xml +++ b/app/src/main/res/layout-land/tutorial_slide4.xml @@ -1,6 +1,5 @@ diff --git a/app/src/main/res/layout/activity_help.xml b/app/src/main/res/layout/activity_help.xml index 350cb96..1b7d3c5 100644 --- a/app/src/main/res/layout/activity_help.xml +++ b/app/src/main/res/layout/activity_help.xml @@ -16,7 +16,7 @@ android:fitsSystemWindows="true" tools:context="org.secuso.privacyfriendly2048.activities.MainActivity"> - + - - + - - + - - + + + android:layout_marginBottom="@dimen/activity_horizontal_margin" /> @@ -114,6 +117,7 @@ android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> + + + + android:layout_marginBottom="@dimen/activity_horizontal_margin" /> @@ -114,6 +117,7 @@ android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> + + + + android:layout_marginBottom="@dimen/activity_horizontal_margin" /> @@ -114,6 +117,7 @@ android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> + + + + android:layout_marginBottom="@dimen/activity_horizontal_margin" /> @@ -114,6 +117,7 @@ android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"> + + + android:src="@mipmap/ic_logo" /> - + xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/app/src/main/res/layout/tutorial_slide2.xml b/app/src/main/res/layout/tutorial_slide2.xml index d779dc7..8337a8b 100644 --- a/app/src/main/res/layout/tutorial_slide2.xml +++ b/app/src/main/res/layout/tutorial_slide2.xml @@ -1,6 +1,5 @@ diff --git a/app/src/main/res/layout/tutorial_slide3.xml b/app/src/main/res/layout/tutorial_slide3.xml index 1832ea0..22c582b 100644 --- a/app/src/main/res/layout/tutorial_slide3.xml +++ b/app/src/main/res/layout/tutorial_slide3.xml @@ -1,6 +1,5 @@ diff --git a/app/src/main/res/layout/tutorial_slide4.xml b/app/src/main/res/layout/tutorial_slide4.xml index 802b948..733bfe2 100644 --- a/app/src/main/res/layout/tutorial_slide4.xml +++ b/app/src/main/res/layout/tutorial_slide4.xml @@ -1,6 +1,5 @@ diff --git a/app/src/main/res/menu/menu_stats.xml b/app/src/main/res/menu/menu_stats.xml index f9a2954..3c19376 100644 --- a/app/src/main/res/menu/menu_stats.xml +++ b/app/src/main/res/menu/menu_stats.xml @@ -2,8 +2,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".activities.StatsActivity"> - + android:orderInCategory="100" + app:showAsAction="never" /> \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 690d2c1..15419d6 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -43,12 +43,12 @@ Über Version: v %s - Autoren: - Saskia Jacob und Julian Wadephul - und Mitwirkende. - In Zusammenarbeit mit - Diese App gehört zur Gruppe der Privacy Friendly Apps entwickelt von dem Karlsruher Institut für Technologie (KIT). Quelltext lizenziert unter GPLv3. Bilder copyright KIT und Google Inc. - Weitere Infos unter: + Autoren: + Saskia Jacob und Julian Wadephul + und Mitwirkende. + In Zusammenarbeit mit + Diese App gehört zur Gruppe der Privacy Friendly Apps entwickelt von dem Karlsruher Institut für Technologie (KIT). Quelltext lizenziert unter GPLv3. Bilder copyright KIT und Google Inc. + Weitere Infos unter: diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 43ab7c3..8329aff 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -45,11 +45,6 @@ #73B2D6 - - - - - #026499 diff --git a/app/src/main/res/values/drawables.xml b/app/src/main/res/values/drawables.xml index 3505456..7abc06d 100644 --- a/app/src/main/res/values/drawables.xml +++ b/app/src/main/res/values/drawables.xml @@ -1 +1 @@ - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 59fb812..d649ccd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -49,7 +49,7 @@ Version: v %s Authors: - Saskia Jacob and Julian Wadephul + Saskia Jacob and Julian Wadephul and contributors. In affiliation with This application belongs to the group of Privacy Friendly Apps developed by Karlsruhe Institute of Technology (KIT). Sourcecode licensed under GPLv3. Images copyright KIT and Google Inc. @@ -101,5 +101,4 @@ Reset Statistics - diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index b07c11e..7f1ae95 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -1,5 +1,4 @@ - +