Version 2.2

This commit is contained in:
mmk2410 2015-05-15 22:19:23 +02:00
parent 2d8bf539ae
commit d682999421
11 changed files with 146 additions and 63 deletions

View file

@ -39,4 +39,6 @@
</activity>
</application>
<uses-permission android:name="com.android.vending.BILLING" />
</manifest>

View file

@ -34,6 +34,9 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.TransactionDetails;
import de.marcelkapfer.morseconverter.engine.DecodeNormalMorseManager;
import de.marcelkapfer.morseconverter.engine.DecodeWrittenMorseManager;
import de.marcelkapfer.morseconverter.engine.EncodeNormalMorseManager;
@ -45,29 +48,47 @@ import de.marcelkapfer.morseconverter.fragments.writtenMorseListFragment;
import it.neokree.materialnavigationdrawer.MaterialNavigationDrawer;
import it.neokree.materialnavigationdrawer.elements.MaterialSection;
import it.neokree.materialnavigationdrawer.elements.listeners.MaterialSectionListener;
import it.neokree.materialnavigationdrawer.util.MaterialActionBarDrawerToggle;
public class MainActivity extends MaterialNavigationDrawer {
public class MainActivity extends MaterialNavigationDrawer implements BillingProcessor.IBillingHandler {
//Declaring the Material Sections
private MaterialSection writtenMorse, normalMorse, writtenMorseList, about;
MaterialActionBarDrawerToggle mDrawerToggle;
private MaterialSection writtenMorse, normalMorse, writtenMorseList, donate, about;
private MaterialActionBarDrawerToggle mDrawerToggle;
BillingProcessor bp;
//The MaterialNavigationDrawer init() methode replaces the normal onCreate() methode
@Override
public void init(Bundle savedInstanceState) {
bp = new BillingProcessor(this, "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkmhshG72hHv9OmduVGxio5jyhC9M4CRGp099vtYHmZGaVCq/hpzUhgu7z/H3ioPSc325W13o3qYGpY4GLwe7MAtnSfTIT2fBu6l3kv9lgyYG0qSnDxZVOikf4Bfj7LE/g1OEr/++MqcD2hg1EBMqIgVyB6qOXgXkrHBSj2pf2Rko1SXNmeZ/MiTFx1VRB0PPRf01hPWU1bxZUizh3hdgWiATuTJCCYR0vpfb4IlQDF5wGS4AGHgIz5Qhh5ZZ+XQDTHv7SDdodSdLc02a/Zy0/9bxTIh8yy/Lg1JbPdh5rvWK/HeEH/wAYmwc8xQoQL264wjTQqKUZ+7iisHwS9ZtowIDAQAB", this);
// Restore purchases
bp.loadOwnedPurchasesFromGoogle();
Resources res = getResources();
//Declaring the Material Sections
writtenMorse = this.newSection("writtenMorse", new MainFragment());
normalMorse = this.newSection(res.getString(R.string.normalMorse), new MorseFragment());
writtenMorseList = this.newSection("writtenMorse Codes", new writtenMorseListFragment()); //TODO rename
writtenMorseList = this.newSection("writtenMorse Codes", new writtenMorseListFragment());
about = this.newSection(res.getString(R.string.about), new AboutFragment());
donate = this.newSection(res.getString(R.string.donate_title), new MaterialSectionListener() {
@Override
public void onClick(MaterialSection materialSection) {
bp.purchase(MainActivity.this, "donate");
donate.unSelect();
}
}
);
//Adding the Sections
this.addSection(writtenMorse);
this.addSection(normalMorse);
this.addDivisor();
this.addSection(writtenMorseList);
this.addBottomSection(donate);
this.addBottomSection(about);
//set drawer image
this.setDrawerHeaderImage(this.getResources().getDrawable(R.drawable.feature_graphics));
@ -105,6 +126,51 @@ public class MainActivity extends MaterialNavigationDrawer {
}
// IBillingHandler implementation
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!bp.handleActivityResult(requestCode, resultCode, data))
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public void onBillingInitialized() {
/*
* Called then BillingProcessor was initialized and its ready to purchase
*/
}
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
/*
* Called then requested PRODUCT ID was successfully purchased
*/
}
@Override
public void onBillingError(int errorCode, Throwable error) {
/*
* Called then some error occured. See Constants class for more details
*/
}
@Override
public void onPurchaseHistoryRestored() {
/*
* Called then purchase history was restored and the list of all owned PRODUCT ID's
* was loaded from Google Play
*/
}
@Override
public void onDestroy() {
if (bp != null)
bp.release();
super.onDestroy();
}
public void normalMorseEncode(View view){
try{
EditText input = (EditText) findViewById(R.id.editTextNormalMorse);
@ -286,4 +352,5 @@ public class MainActivity extends MaterialNavigationDrawer {
ClipData clip = ClipData.newPlainText("Message", string);
clipboard.setPrimaryClip(clip);
}
}

View file

@ -36,9 +36,9 @@
<string name="about">Über</string>
<string name="normalMorse">Normales Morse</string>
<string name="aboutBug">Wenn Du einen Fehler gefunden hast, schreibe mit bitte ein Email an marcelmichaelkapfer@yahoo.co.nz</string>
<string name="aboutHow">Du kannst eine ausführliche Anwendung auf marcel-kapfer.de/projects/morse/index.html#howto_android finden.</string>
<string name="aboutHow">Du kannst eine ausführliche Anwendung auf marcel-kapfer.de/writtenmorse/index.html#howto_android finden.</string>
<string name="aboutMissing">Wenn du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine Email an marcelmichaelkapfer@yahoo.co.nz.</string>
<string name="aboutVersion">2.1 \n10. März 2015</string>
<string name="aboutVersion">2.2 beta \n15. Mai 2015</string>
<string name="sectionBug">Fehler</string>
<string name="sectionContact">Kontakt</string>
<string name="sectionDeveloper">Entwickler</string>
@ -48,4 +48,7 @@
<!--Output Text Buttons-->
<string name="button_share">TEILEN</string>
<string name="button_copy">KOPIEREN</string>
<!--Donate Dialog-->
<string name="donate_title">Unterstütze den Entwickler</string>
</resources>

View file

@ -82,4 +82,9 @@
<item name="android:layout_width">match_parent</item>
</style>
<style name="RippleField">
<item name="android:background">@drawable/button_action</item>
<item name="android:src">@color/cardview_light_background</item>
</style>
</resources>

View file

@ -43,13 +43,13 @@
<string name="sectionHow">How to</string>
<string name="sectionMissing">Missing Code</string>
<!--About Texts-->
<string name="aboutVersion">2.1\n10th March 2015</string>
<string name="aboutVersion">2.2 beta\n15 May 2015</string>
<string name="aboutDeveloper" translatable="false">Marcel Michael Kapfer</string>
<string name="aboutWebsite" translatable="false">marcel-kapfer.de/projects/morse/</string>
<string name="aboutWebsite" translatable="false">marcel-kapfer.de/writtenmorse</string>
<string name="aboutContact" translatable="false">marcelmichaelkapfer@yahoo.co.nz</string>
<string name="aboutLicense" translatable="false">GNU GPL v3.0</string>
<string name="aboutBug">If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.</string>
<string name="aboutHow">You can find a detailed guide on marcel-kapfer.de/projects/morse/index.html#howto_android</string>
<string name="aboutHow">You can find a detailed guide on marcel-kapfer.de/writtenmorse/index.php#howto_android</string>
<string name="aboutMissing">If you discovered, that code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.</string>
<!--Drawer Titles-->
<string name="about">About</string>
@ -58,6 +58,7 @@
<string name="button_share">SHARE</string>
<string name="button_copy">COPY</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<!--Donate Dialog-->
<string name="donate_title">Donate the developer</string>
</resources>

View file

@ -81,4 +81,9 @@
<item name="android:layout_width">match_parent</item>
</style>
<style name="RippleField">
<item name="android:background">@drawable/button_action</item>
<item name="android:src">@color/cardview_light_background</item>
</style>
</resources>