Skip to content

Commit

Permalink
Migration to androidx.
Browse files Browse the repository at this point in the history
Added new tutorial screen. Fixes #8
v1.5.0
  • Loading branch information
Kamuno committed Jun 4, 2020
1 parent 6a4264c commit 4ed8dac
Show file tree
Hide file tree
Showing 24 changed files with 443 additions and 116 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
20 changes: 10 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<application
android:allowBackup="true"
android:icon="@mipmap/launcher_icon_dicer"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
Expand All @@ -22,24 +22,24 @@
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar">
</activity>
android:theme="@style/AppTheme.NoActionBar"/>
<activity
android:name=".AboutActivity"
android:label="@string/about"
android:parentActivityName=".MainActivity">
</activity>

android:parentActivityName=".MainActivity"/>
<activity
android:name=".HelpActivity"
android:label="Help"
android:parentActivityName=".MainActivity">
</activity>
android:parentActivityName=".MainActivity"/>
<activity
android:name=".SettingsActivity"
android:label="@string/settings_title"
android:parentActivityName=".MainActivity">
</activity>
android:parentActivityName=".MainActivity"/>
<activity
android:name=".TutorialActivity"
android:label="@string/slide1_heading"
android:theme="@style/AppTheme.NoActionBar"
android:parentActivityName=".MainActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.secuso.privacyfriendlydicer;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.secuso.privacyfriendlydicer;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

/**
* Created by yonjuni on 15.06.16.
Expand Down
70 changes: 16 additions & 54 deletions app/src/main/java/org/secuso/privacyfriendlydicer/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package org.secuso.privacyfriendlydicer;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Display;
import com.google.android.material.navigation.NavigationView;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.view.MenuItem;
import android.view.View;
import android.view.animation.AlphaAnimation;
Expand Down Expand Up @@ -54,8 +51,6 @@ protected void onCreate(Bundle savedInstanceState) {
drawer.setDrawerListener(toggle);
toggle.syncState();

doFirstRun();

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);

Expand Down Expand Up @@ -271,62 +266,29 @@ public boolean onNavigationItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.nav_about:
intent = new Intent(this, AboutActivity.class);
startActivityForResult(intent, 0);
startActivity(intent);
return true;

case R.id.nav_help:
intent = new Intent(this, HelpActivity.class);
startActivityForResult(intent, 0);
startActivity(intent);
return true;

case R.id.nav_settimgs:
intent = new Intent(this, SettingsActivity.class);
startActivityForResult(intent, 0);
startActivity(intent);
return true;

case R.id.nav_tutorial:
intent = new Intent(this, TutorialActivity.class);
startActivity(intent);
return true;

default:
}

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}

private void doFirstRun() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
sharedPreferences.edit().putString("firstShow", "").apply();
SharedPreferences settings = getSharedPreferences("firstShow", getBaseContext().MODE_PRIVATE);
if (settings.getBoolean("isFirstRun", true)) {
welcomeDialog();
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("isFirstRun", false);
editor.apply();
}
}

public void welcomeDialog() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

alertDialog.setTitle(R.string.welcome_title);

alertDialog.setMessage(R.string.welcome_description);

alertDialog.setIcon(R.mipmap.drawer_icon_dicer);

alertDialog.setPositiveButton(getString(R.string.confirm_button), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
}
});

final Intent intent = new Intent(this, HelpActivity.class);
alertDialog.setNegativeButton(getString(R.string.help_button), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivityForResult(intent, 0);
dialog.cancel();
}
});

alertDialog.show();
}


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.secuso.privacyfriendlydicer;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

/**
* Created by yonjuni on 15.06.16.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.secuso.privacyfriendlydicer;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;

/**
* Created by yonjuni on 22.10.16.
Expand All @@ -14,10 +15,17 @@ public class SplashActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
SharedPreferences settings = getSharedPreferences("firstShow", getBaseContext().MODE_PRIVATE);

Intent intent;
if (settings.getBoolean("isFirstRun", true)) {
intent = new Intent(SplashActivity.this, TutorialActivity.class);
} else {
intent = new Intent(SplashActivity.this, MainActivity.class);
}

startActivity(intent);
finish();
}

}
Loading

0 comments on commit 4ed8dac

Please sign in to comment.