Skip to content

Commit

Permalink
Something is working..
Browse files Browse the repository at this point in the history
  • Loading branch information
mareklangiewicz committed Oct 4, 2015
1 parent 5ea3119 commit 4537b39
Show file tree
Hide file tree
Showing 50 changed files with 570 additions and 83 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
MyBlocks
MyIntent
----
* TODO: description

* TODO: implement local menu API exactly as options menu API is implemented! (MyFragment)

* TODO: implement some API for main FAB (so it is easly accessable from MyFragment)

2 changes: 1 addition & 1 deletion myactivities/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="pl.mareklangiewicz.myactivities"></manifest>
<manifest package="pl.mareklangiewicz.myactivities"/>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pl.mareklangiewicz.myactivities;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
Expand Down Expand Up @@ -45,6 +46,7 @@
import static pl.mareklangiewicz.myutils.MyTextUtils.str;
// TODO LATER: use Leak Canary: https://github.com/square/leakcanary (check U+2020 example...)

@SuppressLint("Registered")
public class MyActivity extends AppCompatActivity implements IMyManager, IMyNavigation.Listener, DrawerLayout.DrawerListener {


Expand All @@ -62,7 +64,7 @@ public class MyActivity extends AppCompatActivity implements IMyManager, IMyNavi
*/
private static final boolean V = true;
private static final boolean VV = false;
private static final String DEFAULT_COMMAND_NAME = "activity";
private static final String DEFAULT_COMMAND_NAME = MyCommands.CMD_ACTIVITY;
private static final String DEFAULT_INTENT_ACTION = Intent.ACTION_VIEW;
protected final MyLivingDrawable mGlobalArrowDrawable = new MyArrowDrawable();
protected final MyLivingDrawable mLocalArrowDrawable = new MyArrowDrawable();
Expand Down Expand Up @@ -315,7 +317,7 @@ public void onCommand(@NonNull String command) {
map.put("start", start);
}

if(start.equals("activity")) {
if(start.equals(MyCommands.CMD_ACTIVITY)) {
if(component == null && action == null) {
action = DEFAULT_INTENT_ACTION;
map.put("action", action);
Expand All @@ -325,7 +327,7 @@ public void onCommand(@NonNull String command) {
map.put("component", component);
}
}
else if(map.get("start").equals("fragment")) {
else if(map.get("start").equals(MyCommands.CMD_FRAGMENT)) {
if(component == null) {
log.e("Fragment component is null.");
return;
Expand All @@ -348,16 +350,16 @@ else if(map.get("start").equals("fragment")) {
public void onCommand(@NonNull Map<String, String> command) {

switch(command.get("start")) {
case "activity":
case MyCommands.CMD_ACTIVITY:
onCommandStartActivity(command);
break;
case "service":
case MyCommands.CMD_SERVICE:
onCommandStartService(command);
break;
case "broadcast":
case MyCommands.CMD_BROADCAST:
onCommandStartBroadcast(command);
break;
case "fragment":
case MyCommands.CMD_FRAGMENT:
onCommandStartFragment(command);
break;
default:
Expand Down Expand Up @@ -422,6 +424,7 @@ public void onCommandStartFragment(@NonNull Map<String, String> command) {

updateLocalFragment(f);

@SuppressLint("CommitTransaction")
FragmentTransaction ft = fm.beginTransaction().replace(R.id.ma_local_frame_layout, f, TAG_LOCAL_FRAGMENT);
addAllSharedElementsToFragmentTransaction(findViewById(R.id.ma_local_frame_layout), ft);
ft.commit();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pl.mareklangiewicz.myactivities;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.view.MenuItem;
Expand All @@ -10,6 +11,7 @@
* Created by Marek Langiewicz on 22.09.15.
* Simple example activity using MyBlock stuff...
*/
@SuppressLint("Registered")
public class MyExampleActivity extends MyActivity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class MyTestActivity extends pl.mareklangiewicz.myactivities.MyActi
mMyMagicLinesDrawable.setColor(0x30ffffff).setStrokeWidth(dp2px(4));
underline.setBackground(mMyMagicLinesDrawable);

View homepage = getGlobalNavigation().getHeader().findViewById(R.id.my_home_page_text_view);
View homepage = getGlobalNavigation().getHeader().findViewById(R.id.text_home_page);

PropertyValuesHolder pvha = PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 0f, 1f);
PropertyValuesHolder pvhy = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -50f, -50f, 0f);
Expand Down
2 changes: 1 addition & 1 deletion myactivities/src/main/res/layout/my_test_global_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
>

<TextView
android:id="@+id/my_home_page_text_view"
android:id="@+id/text_home_page"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion mydrawables/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="pl.mareklangiewicz.mydrawables"></manifest>
<manifest package="pl.mareklangiewicz.mydrawables"/>
2 changes: 1 addition & 1 deletion myfragments/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="pl.mareklangiewicz.myfragments"></manifest>
<manifest package="pl.mareklangiewicz.myfragments"/>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion mytestapp/build.gradle → myintent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "pl.mareklangiewicz.mytestapp"
applicationId "pl.mareklangiewicz.myintent"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
Expand Down
Binary file added myintent/ic_launcher_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added myintent/ic_launcher_web_g1r2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pl.mareklangiewicz.mytestapp;
package pl.mareklangiewicz.myintent;

import android.app.Application;
import android.test.ApplicationTestCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,29 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.mareklangiewicz.mytestapp"
>
package="pl.mareklangiewicz.myintent">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
<!-- TODO SOMEDAY: automatic backup for user defined RE rules. (to synchronize between marshmallow devices)-->

<application android:allowBackup="false"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
android:icon="@mipmap/ic_launcher"
android:supportsRtl="false"
android:theme="@style/AppTheme">
<activity
android:name="pl.mareklangiewicz.myactivities.MyTestActivity"
android:label="@string/title_my_test_activity"
android:name=".MIActivity"
android:label="@string/title_mi_activity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="pl.mareklangiewicz.myactivities.MyExampleActivity"
android:label="@string/title_my_example_activity"
/>
<activity
android:name="pl.mareklangiewicz.mytestapp.MyExampleActivity2"
android:label="@string/title_my_example_activity_2"
android:name="pl.mareklangiewicz.myactivities.MyTestActivity"
android:label="TMP:MyTestActivity"
/>

</application>

</manifest>
143 changes: 143 additions & 0 deletions myintent/src/main/java/pl/mareklangiewicz/myintent/MIActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package pl.mareklangiewicz.myintent;

import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.view.MenuItem;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;

import pl.mareklangiewicz.myactivities.MyActivity;
import pl.mareklangiewicz.mydrawables.MyLivingDrawable;
import pl.mareklangiewicz.mydrawables.MyMagicLinesDrawable;
import pl.mareklangiewicz.myviews.IMyNavigation;

/**
* Created by Marek Langiewicz on 02.10.15.
* My Intent main activity.
*/
public class MIActivity extends MyActivity{

private @Nullable MyLivingDrawable mMyMagicLinesDrawable;
private @Nullable View mMagicLinesView;
@SuppressWarnings("unused")
private @Nullable ImageView mLogoImageView;
private @Nullable TextView mLogoTextView;
private @Nullable TextView mHomePageTextView;
private @Nullable ObjectAnimator mLogoTextViewAnimator;
private @Nullable ObjectAnimator mHomePageTextViewAnimator;
private @Nullable ObjectAnimator mMagicLinesDrawableAnimator;

@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

log.i("TODO: hello, and where is help..");

//noinspection ConstantConditions
getGlobalNavigation().inflateMenu(R.menu.mi_menu);
getGlobalNavigation().inflateHeader(R.layout.mi_header);


//noinspection ConstantConditions
mMyMagicLinesDrawable = new MyMagicLinesDrawable();
mMyMagicLinesDrawable.setColor(0x30ffffff).setStrokeWidth(dp2px(4));
//noinspection ConstantConditions
mMagicLinesView = getGlobalNavigation().getHeader().findViewById(R.id.magic_underline_view);
mMagicLinesView.setBackground(mMyMagicLinesDrawable);
mLogoImageView = (ImageView) getGlobalNavigation().getHeader().findViewById(R.id.image_logo);
mLogoTextView = (TextView) getGlobalNavigation().getHeader().findViewById(R.id.text_logo);
mHomePageTextView = (TextView) getGlobalNavigation().getHeader().findViewById(R.id.text_home_page);
//noinspection ConstantConditions
mHomePageTextView.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
onCommand("data " + getResources().getString(R.string.user_id));
}
});

PropertyValuesHolder pvha1 = PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 0.2f, 1f);
PropertyValuesHolder pvhy1 = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -130f, -30f, 0f);
PropertyValuesHolder pvha2 = PropertyValuesHolder.ofFloat(View.ALPHA, 0f, 0f, 0.7f);
PropertyValuesHolder pvhy2 = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -50f, -50f, 0f);

mLogoTextViewAnimator = ObjectAnimator.ofPropertyValuesHolder(mLogoTextView, pvha1, pvhy1);
mHomePageTextViewAnimator = ObjectAnimator.ofPropertyValuesHolder(mHomePageTextView, pvha2, pvhy2);
mLogoTextViewAnimator.setInterpolator(new LinearInterpolator());
mHomePageTextViewAnimator.setInterpolator(new LinearInterpolator());

mMagicLinesDrawableAnimator = ObjectAnimator.ofInt(mMyMagicLinesDrawable, "level", 0, 10000);
mMagicLinesDrawableAnimator.setDuration(1000).setInterpolator(new LinearInterpolator());

if(savedInstanceState == null) {
selectGlobalItem(R.id.mi_start);
}
}

@Override protected void onDestroy() {

mMagicLinesDrawableAnimator = null;
mHomePageTextViewAnimator = null;
mLogoTextViewAnimator = null;
mHomePageTextView = null;
mLogoTextView = null;
mLogoImageView = null;
mMagicLinesView = null;
mMyMagicLinesDrawable = null;

super.onDestroy();
}

@Override public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
if(drawerView != mGlobalNavigationView)
return;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
if(mLogoTextViewAnimator != null)
mLogoTextViewAnimator.setCurrentFraction(slideOffset);
if(mHomePageTextViewAnimator != null)
mHomePageTextViewAnimator.setCurrentFraction(slideOffset);
}
}


@Override public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
if(drawerView != mGlobalNavigationView)
return;
if(mMagicLinesDrawableAnimator != null)
if(!mMagicLinesDrawableAnimator.isStarted())
mMagicLinesDrawableAnimator.start();
}

@Override public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
if(drawerView != mGlobalNavigationView)
return;
if(mMagicLinesDrawableAnimator != null)
mMagicLinesDrawableAnimator.cancel();
if(mMyMagicLinesDrawable != null)
mMyMagicLinesDrawable.setLevel(0);
}

@Override public boolean onItemSelected(IMyNavigation nav, MenuItem item) {

boolean done = super.onItemSelected(nav, item);

if(done)
return true;

@IdRes int id = item.getItemId();

if(id == R.id.action_whats_up) {
log.i("[SNACK][SHORT]What's up mate?");
return true;
}

return false;
}

}
Loading

0 comments on commit 4537b39

Please sign in to comment.