Skip to content

Commit

Permalink
V 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pulce committed May 30, 2016
1 parent 8165ac0 commit 74bc26e
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 65 deletions.
2 changes: 0 additions & 2 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
Expand All @@ -102,7 +101,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.windnow"
android:versionCode="10"
android:versionName="2.2.0" >
android:versionCode="11"
android:versionName="2.2.1" >

<uses-sdk
android:minSdkVersion="8"
Expand All @@ -12,13 +12,13 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name="com.windnow.statics.OnlyContext"
android:name=".OnlyContext"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.windnow.MainActivity"
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -41,7 +41,7 @@
</intent-filter>
</activity>
<activity
android:name="com.windnow.StationActivity"
android:name=".StationActivity"
android:label="@string/title_activity_station_text" >
</activity>
<activity
Expand Down
41 changes: 37 additions & 4 deletions app/src/main/java/com/windnow/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import com.windnow.preferences.FilePreferenceFragment;
import com.windnow.preferences.UserPreferencesFragment;
import com.windnow.statics.LoadSaveOps;
import com.windnow.statics.OnlyContext;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.app.Dialog;
import android.content.DialogInterface;
Expand All @@ -23,13 +24,14 @@
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
Expand Down Expand Up @@ -68,7 +70,7 @@
public class MainActivity extends AppCompatActivity implements
InterfaceDlUpdate, MainFragment.Callbacks {

public static final String VERSIONID = "2.2.0";
public static final String VERSIONID = "2.2.1";
public static final String APPURL = "https://github.com/pulce/WindNow/releases/latest";

private String sharedUrl = null;
Expand All @@ -79,6 +81,8 @@ public class MainActivity extends AppCompatActivity implements
public static final ArrayList<Station> objects = new ArrayList<>();

private static final String LIST_STATE = "listState";
private static final int PERMISSION_WRITE_STORAGE = 42;
private static boolean writePermitted = false;

private boolean mTwoPane;
private Station activeStation;
Expand All @@ -95,6 +99,17 @@ public class MainActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
writePermitted = (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED);
if (!writePermitted) {
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
Toast.makeText(this, R.string.permission_info, Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
PERMISSION_WRITE_STORAGE);
}
}
setContentView(R.layout.activity_main_list);
setTitle(R.string.app_name);
if (findViewById(R.id.station_container) != null) {
Expand Down Expand Up @@ -519,7 +534,7 @@ public ArrayList<Station> getObjects() {
}

public static ArrayList<Station> getStaticObjects(Context context) {
if (objects.size() == 0) {
if (objects.size() == 0 && writePermitted) {
try {
objects.addAll(LoadSaveOps.loadStations());
} catch (Exception e) {
Expand All @@ -532,4 +547,22 @@ public static ArrayList<Station> getStaticObjects(Context context) {
return objects;
}

@Override
public void onRequestPermissionsResult(int requestCode,
@NonNull String permissions[], @NonNull int[] grantResults) {
switch (requestCode) {
case PERMISSION_WRITE_STORAGE: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
writePermitted = true;
Intent intent = getIntent();
finish();
startActivity(intent);
} else {
Toast.makeText(this, R.string.permission_info, Toast.LENGTH_LONG).show();
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package com.windnow.statics;
package com.windnow;

import android.Manifest;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;

import com.windnow.MainActivity;

/**
*
Expand Down
42 changes: 41 additions & 1 deletion app/src/main/java/com/windnow/Station.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package com.windnow;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.annotation.NonNull;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.StringReader;
import java.text.DateFormat;
Expand All @@ -18,7 +27,6 @@
import org.jsoup.select.Elements;

import com.windnow.statics.LoadSaveOps;
import com.windnow.statics.OnlyContext;

/**
*
Expand Down Expand Up @@ -389,6 +397,38 @@ public static ArrayList<String> parseAC(Document doc) throws Exception {
return patschText;
}

/*
public static ArrayList<String> parseACTAB(Document doc) throws Exception {
String text = doc.toString();
final Rect bounds = new Rect();
TextPaint textPaint = new TextPaint() {
{
setColor(Color.WHITE);
setTextAlign(Paint.Align.LEFT);
setTextSize(20f);
setAntiAlias(true);
}
};
textPaint.getTextBounds(text, 0, text.length(), bounds);
StaticLayout mTextLayout = new StaticLayout(text, textPaint,
bounds.width(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
int maxWidth = -1;
for (int i = 0; i < mTextLayout.getLineCount(); i++) {
if (maxWidth < mTextLayout.getLineWidth(i)) {
maxWidth = (int) mTextLayout.getLineWidth(i);
}
}
final Bitmap bmp = Bitmap.createBitmap(maxWidth , mTextLayout.getHeight(),
Bitmap.Config.ARGB_8888);
bmp.eraseColor(Color.BLACK);// just adding black background
final Canvas canvas = new Canvas(bmp);
mTextLayout.draw(canvas);
FileOutputStream stream = new FileOutputStream(...); //create your FileOutputStream here
bmp.compress(Bitmap.CompressFormat.PNG, 85, stream);
bmp.recycle();
stream.close();
return patschText;
}*/

public static String toCamelCase(String inputString) {
String result = "";
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/windnow/StationListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.List;

import com.windnow.statics.OnlyContext;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/windnow/classes/DownloadStation.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.windnow.Station;
import com.windnow.statics.LoadSaveOps;
import com.windnow.statics.OnlyContext;
import com.windnow.OnlyContext;

/**
*
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/windnow/classes/NavItem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.windnow.classes;

import com.windnow.statics.OnlyContext;
import com.windnow.OnlyContext;

/**
* This Class is part of WindNow.
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/windnow/statics/LoadSaveOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Arrays;
import java.util.Date;

import com.windnow.OnlyContext;
import com.windnow.Station;

import android.annotation.SuppressLint;
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<string name="title_activity_station_pic">Station</string>
<string name="title_activity_settings">Einstellungen</string>
<string name="authors_note"> Contact: [email protected] \n
Copyright 2015 \n
Copyright 2015 - 2016 \n
by Florian Hauser</string>
<string name="legal_notice"> Dependencies:\n
jsoup - http://jsoup.org/ \n
Expand Down Expand Up @@ -87,4 +87,5 @@ Es gibt drei Möglichkeiten um neue Stationen anzulegen:\n
<string name="drawer_open">Navigation öffnen</string>
<string name="userprefs_username">Benutzername</string>
<string name="userprefs_password">Passwort</string>
<string name="permission_info">Fehlende Berechtigung zum Zugriff auf das Dateisystem. Diese Berechtigung ist nötig um die Datei stations.txt zu benutzen.</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<string name="title_activity_station_pic">Station</string>
<string name="title_activity_settings">Settings</string>
<string name="authors_note"> Contact: [email protected] \n
Copyright 2015 \n
Copyright 2015 - 2016 \n
by Florian Hauser</string>
<string name="legal_notice"> Dependencies:\n
jsoup - http://jsoup.org/ \n
Expand Down Expand Up @@ -87,4 +87,5 @@ There are three ways to create new stations:\n
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
<string name="successfully_saved">"Successfully saved "</string>
<string name="permission_info">No permission for access to external storage - this permission is needed for the app to access stations.txt</string>
</resources>
Loading

0 comments on commit 74bc26e

Please sign in to comment.