forked from codeka/wwmmo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted WarmWelcomeFragment to screen+layout.
- Loading branch information
Showing
5 changed files
with
110 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
client/src/main/java/au/com/codeka/warworlds/client/game/welcome/WarmWelcomeFragment.java
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
client/src/main/java/au/com/codeka/warworlds/client/game/welcome/WarmWelcomeLayout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package au.com.codeka.warworlds.client.game.welcome; | ||
|
||
import android.content.Context; | ||
import android.widget.RelativeLayout; | ||
import au.com.codeka.warworlds.client.R; | ||
import au.com.codeka.warworlds.client.ctrl.TransparentWebView; | ||
import au.com.codeka.warworlds.client.util.ViewBackgroundGenerator; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Layout for {@link WarmWelcomeScreen}. | ||
*/ | ||
public class WarmWelcomeLayout extends RelativeLayout { | ||
public interface Callbacks { | ||
void onStartClick(); | ||
void onPrivacyPolicyClick(); | ||
void onHelpClick(); | ||
} | ||
|
||
private final Callbacks callbacks; | ||
|
||
public WarmWelcomeLayout(Context context, @Nonnull Callbacks callbacks) { | ||
super(context); | ||
inflate(context, R.layout.frag_warm_welcome, this); | ||
this.callbacks = callbacks; | ||
|
||
ViewBackgroundGenerator.setBackground(this); | ||
|
||
TransparentWebView welcome = findViewById(R.id.welcome); | ||
String msg = TransparentWebView.getHtmlFile(getContext(), "html/warm-welcome.html"); | ||
welcome.loadHtml("html/skeleton.html", msg); | ||
|
||
findViewById(R.id.next_btn).setOnClickListener(v -> callbacks.onStartClick()); | ||
findViewById(R.id.help_btn).setOnClickListener(v -> callbacks.onHelpClick()); | ||
findViewById(R.id.privacy_policy_btn).setOnClickListener(v -> callbacks.onPrivacyPolicyClick()); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
client/src/main/java/au/com/codeka/warworlds/client/game/welcome/WarmWelcomeScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package au.com.codeka.warworlds.client.game.welcome; | ||
|
||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import au.com.codeka.warworlds.client.R; | ||
import au.com.codeka.warworlds.client.activity.BaseFragment; | ||
import au.com.codeka.warworlds.client.activity.SharedViewHolder; | ||
import au.com.codeka.warworlds.client.ctrl.TransparentWebView; | ||
import au.com.codeka.warworlds.client.ui.Screen; | ||
import au.com.codeka.warworlds.client.ui.ScreenContext; | ||
import au.com.codeka.warworlds.client.util.GameSettings; | ||
import au.com.codeka.warworlds.client.util.ViewBackgroundGenerator; | ||
|
||
/** | ||
* This fragment is shown the first time you start the game. We give you a quick intro, some links | ||
* to the website and stuff like that. | ||
*/ | ||
public class WarmWelcomeScreen extends Screen { | ||
private WarmWelcomeLayout layout; | ||
|
||
@Override | ||
public void onCreate(ScreenContext context, LayoutInflater layoutInflater, ViewGroup container) { | ||
layout = new WarmWelcomeLayout(layoutInflater.getContext(), new WarmWelcomeLayout.Callbacks() { | ||
@Override | ||
public void onStartClick() { | ||
// save the fact that we've finished the warm welcome | ||
GameSettings.i.edit() | ||
.setBoolean(GameSettings.Key.WARM_WELCOME_SEEN, true) | ||
.commit(); | ||
|
||
context.pushScreen(new WelcomeScreen()); | ||
// TODO: should be CreateEmpireScreen(). | ||
// getFragmentTransitionManager().replaceFragment( | ||
// CreateEmpireFragment.class, | ||
// SharedViewHolder.builder() | ||
// .addSharedView(R.id.title_icon, "title_icon") | ||
// .addSharedView(R.id.title, "title") | ||
// .addSharedView(R.id.next_btn, "done_btn") | ||
// .build()); | ||
} | ||
|
||
@Override | ||
public void onPrivacyPolicyClick() { | ||
Intent i = new Intent(Intent.ACTION_VIEW); | ||
i.setData(Uri.parse("http://www.war-worlds.com/privacy-policy")); | ||
context.startActivity(i); | ||
} | ||
|
||
@Override | ||
public void onHelpClick() { | ||
Intent i = new Intent(Intent.ACTION_VIEW); | ||
i.setData(Uri.parse("http://www.war-worlds.com/doc/getting-started")); | ||
context.startActivity(i); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public View onShow() { | ||
return layout; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters